You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is tied into a parent which passes props to determine already selected items which works. When I setState in the parent and propagate new props it seems that once mounted with initial props, subsequent updates/renders propagate props as expected but don't update state on SelectableComponent i.e.
props
data
{architecture: "i386", bootupTimeStamp: 1582050413.…}
isSelected
false
new prop
:
"" state
isSelected
true
isSelecting
false
context value
{selectable: {…}} rendered by
List
Devices
Parent
I assumed that you could set the prop isSelected on those that you would like to have selected.
Is there a way of select|deselect after initial render?
I usually prefix my props with default on the uncontrolled ones:
defaultIsSelected <-- used when you want a uncontrolled component
Selected <-- used when you want to have a controlled
Hey!
Not sure if this is a proper way to use this.
{this.props.items.map((item, i) => { let selected = this.props.selected.indexOf(item) > -1; return (<SelectableComponent key={i} data={item} isSelected={selected} />); })}
This is tied into a parent which passes props to determine already selected items which works. When I setState in the parent and propagate new props it seems that once mounted with initial props, subsequent updates/renders propagate props as expected but don't update state on SelectableComponent i.e.
props
data
{architecture: "i386", bootupTimeStamp: 1582050413.…}
isSelected
false
new prop
:
""
state
isSelected
true
isSelecting
false
context
value
{selectable: {…}}
rendered by
List
Devices
Parent
Snippet from React inspector.
Anyway to "deselect" via props ?
#36 (comment)
I guess something like this would work
https://til.hashrocket.com/posts/p8tr2ah430-forcing-a-child-remount-with-the-key-prop
Setting a key on <List> definitely works.
The text was updated successfully, but these errors were encountered: