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

Filter component not re-rendering #1170

Open
jamiek-acl opened this issue Nov 4, 2021 · 1 comment
Open

Filter component not re-rendering #1170

jamiek-acl opened this issue Nov 4, 2021 · 1 comment

Comments

@jamiek-acl
Copy link
Contributor

jamiek-acl commented Nov 4, 2021

In the Filter component I am trying to add an external button that if i click it, it applies another filter. Its not working as seen here (click the "Add Romario filter" button, notice how the filter count does not increase and there is no filter in the side panel): https://codesandbox.io/s/keen-rgb-7lmhg?file=/src/App.js

I got it to work by changing the key of the Filter's parent (click the "Add Romario filter" button, notice how the filter count DOES increase and there is a filter in the side panel): https://codesandbox.io/s/exciting-fast-ur8y8?file=/src/App.js but that unmounts and remounts the entire component unnecessarily.

Allison said:

I think this component should re-render as well
but the paprika filter component won’t recalculate the state
Do you think if it can be fixed by:
- the useFilter hook returns the dispatch  function
- the defaultReducer  adds a new case about updateState
- or we can just export a function called `updateState` from useFilter()  , and don’t export the dispatch
@AndreyChernykh
Copy link
Contributor

The problem is that packages/Filter/src/hooks/useFilter.js accepts filters as an initialState (so it doesn't react on any changes that happen after the initial render)

I believe, the API of this component needs to be reimagined and rewritten.

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

No branches or pull requests

2 participants