Skip to content

Checkbox code sample in docs is incorrect #58

Description

@sircfenner

The code sample:

local function MyComponent()
	local selected, setSelected = React.useState(false)
	return React.createElement(StudioComponents.Checkbox, {
		Value = selected,
		OnChanged = setSelected,
	})
end

... incorrectly assigns OnChanged to setSelected.

OnChanged is called with no values and should actually be used as follows:

local function MyComponent()
	local selected, setSelected = React.useState(false)
	return React.createElement(StudioComponents.Checkbox, {
		Value = selected,
		OnChanged = function()
			setSelected(not selected)
		end,
	})
end

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions