Skip to content

chore: export useControlledState from react-stately and react-aria-components #8620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

reidbarber
Copy link
Member

Closes #6222

Seems fine to export since we use this in React Spectrum v3/S2 people might want to similarly use it without needing to install the individual package. If we have other concerns, I can close this and close the original issue.

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

🧢 Your Project:

@reidbarber reidbarber changed the title export useControlledState from react-stately and react-aria-components chore: export useControlledState from react-stately and react-aria-components Jul 23, 2025
@rspbot
Copy link

rspbot commented Jul 23, 2025

@rspbot
Copy link

rspbot commented Jul 23, 2025

## API Changes

react-aria-components

/react-aria-components:useControlledState

+useControlledState <C = T, T> {
+  value: T
+  defaultValue: T
+  onChange?: (C, Array<any>) => void
+  returnVal: undefined
+}

Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the known limitations, as mentioned in the comment below about setState with prev state, do we actually want to export this? or will this confuse people?

*
* @param value - The controlled value. Pass `undefined` to make the component uncontrolled.
* @param defaultValue - The initial value when uncontrolled.
* @param onChange - Callback fired whenever the value changes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param onChange - Callback fired whenever the value changes.
* @param onChange - Callback fired whenever the value changes.
* @returns [value, (val) => void] - something here about how we don't support the prevState callback on setState?

@reidbarber
Copy link
Member Author

Discussed with the team and we decided not to include in the monopackage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Export useControlledState from react-stately (and/or react-aria-components).
3 participants