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外部设置children的属性,children不更新 #97

Closed
ousiri opened this issue Sep 19, 2022 · 6 comments
Closed

在Provider外部设置children的属性,children不更新 #97

ousiri opened this issue Sep 19, 2022 · 6 comments

Comments

@ousiri
Copy link

ousiri commented Sep 19, 2022

如果在Provider外部设置children的属性,因为IsolatorInner和StoreExecutor使用memo,导致children不更新。即使设置了memo: false。

重现Repo:https://github.com/ousiri/hox-vite-demo
重现步骤:

  1. npm i
  2. npm run dev
  3. 访问 http://127.0.0.1:5173/
  4. 点击"click to change",会发现下面的UserInfo数据不更新
    关键代码:src/App.tsx
const [useUserStore, UserStoreProvider] = createStore(() => {
  return {}
}, { memo: false });

const UserInfo: FC<{ name: string }> = ({ name }) => {
  return <div>{name}</div>
}

function App() {
  const [name, setName] = useState('Demo')

  return (
    <div className="App">
      <UserInfo name={name} /> // 可以正常更新
      <button onClick={() => setName('Demo2')}>click to change</button>
      <UserStoreProvider>
        <UserInfo name={name} /> // 点击后不更新
      </UserStoreProvider>
    </div>
  )
}
@gracezlj
Copy link

gracezlj commented Nov 8, 2022

同样遇到了该问题😶

@AimWhy
Copy link

AimWhy commented Jan 4, 2023

找到解决方式了么?
image
看代码是这里的问题

AimWhy added a commit to AimWhy/hox that referenced this issue Jan 5, 2023
@codering
Copy link

codering commented Jan 9, 2023

@awmleer 这个问题可以解决吗?

@houseBetter
Copy link

解决了吗

@DFNJKD-98
Copy link

应该还没有解决,呜呜呜,排了半天的bug,才发现是这里的问题

@awmleer
Copy link
Member

awmleer commented Jul 12, 2023

非常抱歉拖到现在才修复掉…… ce5f452

已经在 2.1.1 版本发布

@awmleer awmleer closed this as completed Jul 12, 2023
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

7 participants