Skip to content

Commit

Permalink
For update caused by event do rerender even if the value is not chang…
Browse files Browse the repository at this point in the history
…ed on setState from useState hook.
  • Loading branch information
s-yadav committed Aug 24, 2020
1 parent bb62697 commit b81f49e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
UPDATE_TYPE_DEFERRED,
UPDATE_SOURCE_TRANSITION,
BRAHMOS_DATA_KEY,
UPDATE_SOURCE_IMMEDIATE_ACTION,
} from './configs';

import {
Expand Down Expand Up @@ -110,7 +111,11 @@ function isDependenciesChanged(deps, oldDeps) {
* Function to rerender component if state is changed
*/
function reRenderComponentIfRequired(component, state, lastState) {
if (!Object.is(state, lastState)) {
/**
* check if state are different before rerendering, for seState triggered by event
* we should always reRerender as event can have some side effects which are controlled
*/
if (getCurrentUpdateSource() === UPDATE_SOURCE_IMMEDIATE_ACTION || !Object.is(state, lastState)) {
reRender(component);
}
}
Expand Down

0 comments on commit b81f49e

Please sign in to comment.