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

Provider 组件中 useMemo 的含义 #6

Open
94mashiro opened this issue Nov 24, 2019 · 1 comment
Open

Provider 组件中 useMemo 的含义 #6

94mashiro opened this issue Nov 24, 2019 · 1 comment

Comments

@94mashiro
Copy link

94mashiro commented Nov 24, 2019

useMemo(() => {
  setHoox = patch => setState(prevState => Object.assign(
    {},
    prevState,
    patch instanceof Function ? patch(prevState) : patch,
  ));
  resetHoox = setState;
}, []);

你好,在阅读源码的时候有个疑惑,就是 Provider 组件的实现中,有这个使用 useMemo 的操作,这里使用 useMemo 的含义是什么呢,希望作者能解答一下。

@wuomzfx
Copy link
Owner

wuomzfx commented Nov 26, 2019

就是里面的逻辑 不需要重复执行多次,初始化的时候执行一次就好

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