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

fix(useReactive): 修复当使用 delete 操作符时页面不刷新 #904

Merged
merged 1 commit into from
Apr 6, 2021
Merged

fix(useReactive): 修复当使用 delete 操作符时页面不刷新 #904

merged 1 commit into from
Apr 6, 2021

Conversation

dream2023
Copy link
Contributor

demo

const App = () => {
const obj =useReactive({ name: 'zhang', age: 10 })
const handleDeleteName = () => {
  delete obj.name
}
return <div>
  <div>name: {obj.name}</div>
  <button onClick={ () => handleDeleteName() }>删除 name</button>
</div>
}

预期结果:我们需要删除一个属性时,视图应该刷新

实际结果:并未发生变化

解决方案:使用 deleteProperty 拦截 delete 操作,具体情况 packages/hooks/src/useReactive/index.ts 38 行

@CLAassistant
Copy link

CLAassistant commented Apr 2, 2021

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@awmleer awmleer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@awmleer awmleer self-assigned this Apr 6, 2021
@awmleer awmleer merged commit 015c335 into alibaba:master Apr 6, 2021
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

Successfully merging this pull request may close these issues.

3 participants