[filter-panel] React wrapper: Expose component state as something easily consumable by React #7796
Closed
2 tasks done
Labels
adopter support
bug
Something isn't working
dev
Needs some dev work
inactive
severity 4
Affects minor functionality, no workaround needed
The problem
I find it hard to use this component because it needs me to handle the synchronization between the component's internal state and react state. It is quite simple when the filter panel is the only thing that mutates a particular state but making the filter panel react to other components mutating state gets complicated fast and has a lot of imperative code attached to it.
The solution
I would like if the component exposed a consumable piece of state that updates the filter panel when mutated.
Application/website
https://www.ibm.com/events/
Business priority
Low Priority = release date is not dependent on fix or not upcoming
What time frame would this ideally be needed by (if applicable)
No response
Examples
This sandbox shows an implementation I made with the current component. It shows how the component interacts with state that is changed by other components.
One curious edge case I found happens when you:
The filterPanel component will react to the change due to a useEffect, but only the total number of selected filters will be updated, the filter that you just removed from selection will continue with a check.
Similarly, if you selected a filter by using the text input (for example, typing "On demand" and pressing enter) the filter panel would react, the total number of selected filters would update, but the checkbox would continue empty.
This could be solved by including the an method to update the checkboxes in a useEffect but I think this behavior should be included out of the box.
Code of Conduct
The text was updated successfully, but these errors were encountered: