Skip to content
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

Select component mutating props #804

Closed
saby1101 opened this issue Jan 5, 2020 · 4 comments · Fixed by #839
Closed

Select component mutating props #804

saby1101 opened this issue Jan 5, 2020 · 4 comments · Fixed by #839
Labels
🐛 Bug 📱 Components components module-specific

Comments

@saby1101
Copy link

saby1101 commented Jan 5, 2020

🐛 Bug Report

Passing read-only array to Select component (Multi-select mode) causes crash.
"selectedOption is readonly"

To Reproduce

Steps to reproduce the behavior:

  • pass Object.freeze([array]) to selectedOption prop
  • select another option from the UI

Issue is at

Expected behavior

No crash

Link to runnable example or repository (highly encouraged)

UI Kitten and Eva version

Package Version
@ui-kitten/components 4.3.2

Environment information

@artyorsh
Copy link
Collaborator

artyorsh commented Jan 8, 2020

Hi @saby1101
Can you please describe the use-case when Object.freeze needs to be passed?

@artyorsh artyorsh added 📱 Components components module-specific 🤷‍♂️ Needs info There is no enough info to resolve the issue labels Jan 8, 2020
@saby1101
Copy link
Author

saby1101 commented Jan 12, 2020

If you use immerjs, it will use Object.freeze internally on the objects to ensure immutability.

Also, as far as I understand props of a component should not be modified. Quoting from a StackOverflow answer: "A component should manage its own state, but it should not manage its own props. props is essentially "state that is managed by the component owner." That's why props are immutable."

https://stackoverflow.com/questions/47471131/why-are-react-props-immutable

@artyorsh
Copy link
Collaborator

Got it. Let's keep it open so we can back to this in the nearest future. Thanks for reporting 👍
Btw, do you have some workaround on it?

@artyorsh artyorsh added 🐛 Bug and removed 🤷‍♂️ Needs info There is no enough info to resolve the issue labels Jan 13, 2020
@saby1101
Copy link
Author

Currently, I am making a copy of the object and then assigning it to props.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug 📱 Components components module-specific
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants