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

onChange in handleChange is called on every change to store #165

Open
FG-avi opened this issue Jun 11, 2019 · 5 comments
Open

onChange in handleChange is called on every change to store #165

FG-avi opened this issue Jun 11, 2019 · 5 comments

Comments

@FG-avi
Copy link

FG-avi commented Jun 11, 2019

Do you want to request a feature or report a bug?
bug
What is the current behavior?
Any change to the redux store cause the onChange function to be executed. This causes our app to slow down a lot.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:

What is the expected behavior?
For the onChange to only be called when the localize part of the state is changed

Which versions of react and react-localize-redux are you using?
react: 16.8.6
reat-localize-redux: 7.0.3
redux: 4.0.1

Redux suggest something like this
function observeStore(store, select, onChange) {
let currentState;

function handleChange() {
let nextState = select(store.getState());
if (nextState !== currentState) {
currentState = nextState;
onChange(currentState);
}
}

let unsubscribe = store.subscribe(handleChange);
handleChange();
return unsubscribe;
}

reduxjs/redux#303 (comment)

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
@FG-avi and others