-
Notifications
You must be signed in to change notification settings - Fork 1
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
[Bugfix] Dropdown: ensure reactivity of components 'selectedItem' prop #1111
Conversation
The build is failing on linting; |
…onent-library into bugfix/dropdown-component-reactivity
src/components/Input/index.jsx
Outdated
@@ -39,6 +39,8 @@ const Input = forwardRef( | |||
handleChange(e.target.value) | |||
} | |||
|
|||
useEffect(() => setValue(value), [value]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change should be implemented in a separate PR; we are looking into making this component stateless
Quality Gate passedIssues Measures |
Bug: Changing the
selectedItem
prop doesn't rerender the component because it's immediately being captures inside auseState
hook.Fix: Add a
useEffect
hook that runs thesetState
hooks whereselectedItem
is being used to initialise the state hooks.Testing: I tested this by adding a simple component to the storybook and observed that clicking the button to change the selected item works with my fix.