This repository was archived by the owner on Jul 22, 2020. It is now read-only.
fix: async consume for value listener#33
Open
wjw99830 wants to merge 3 commits intozent-contrib:masterfrom
Open
fix: async consume for value listener#33wjw99830 wants to merge 3 commits intozent-contrib:masterfrom
wjw99830 wants to merge 3 commits intozent-contrib:masterfrom
Conversation
Contributor
Author
|
整理了一下eslint配置、error常量集中维护 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
为了避免
react16.13.x的warning,会在useEffect中调用parent.registerChild,这导致组件首次渲染时useFieldValue总是会返回null,当条件渲染的表单组件使用了destroyOnUnmount并结合前述行为时会在某些场景下出现预期之外的行为,例子如下:基于以上场景,需要改变
registerChild的调用时机,保证useFieldValue在首次渲染时总能根据name拿到对应的model,考虑到直接恢复代码会重现react 16.13.x中的warning,因此将value-listener.tsx中的消费行为统一改为异步(rxjs的消费总是同步触发的,即数据源发出消息时立即进行消费)。这么做的缺陷是
childRemove、childRegister在发出消息时,整体上进行了两次re-render,第一次是触发childRemove、childRegister发出数据,此时会存在children的移除或新增导致的re-render,第二次是对该消息进行消费时导致的re-render。