-
Notifications
You must be signed in to change notification settings - Fork 692
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
Infra/useDidUpdate #1112
Infra/useDidUpdate #1112
Conversation
src/hooks/useDidUpdate/index.ts
Outdated
const isDataChanged = useCallback(() => { | ||
return !_.isEqual(_dep.current, dep); | ||
}, [dep]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure there's a need for useCallback here, you don't pass the function reference anywhere..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I should change it to useMemo
to avoid re do the _. isEqual
work
return !_.isEqual(_dep.current, dep); | ||
}, [dep]); | ||
|
||
useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe im missing something..
shouldn't there be a code that prevents from this effect to trigger on initial mount?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the inner dependancies set to be as the passed prop dependancies, it will actually start as the same value..
…-logic * master: Fix lint error cleanup eslintrc file Infra/useDidUpdate (#1112) Support UI presets for Incubator.TextField and set a 'default' preset (#1111) Fix lint issues fix radioButton lint errors and generate types Fix/imageSource deprecation (#1115) Typescript/tab controller move to function component (#1098) Feat/radio button customize styling (#1092) bug fixes for TabBar refactor (#1106) Update ios target to 11 prettify file Fix icon size in badges example screen (#1104) icon prop - fix type to be both number and object. (#1086) enable eslint on both ts and js files (#1101) fix eslint (#1107) # Conflicts: # demo/src/screens/componentScreens/FaderScreen.tsx # src/components/fader/index.tsx # src/components/tabController/FadedScrollView.tsx # src/components/tabController/TabBar.tsx
Description
Added new hook tool - useDidUpdate to avoid getting side effect calls on initial value.
Changelog
Introduce new useDidUpdate hook, that will skip update on initial value.