fix: Patch for getPopupContainer check #200
Merged
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.
getPopupContainer
的参数传入domNode
产生了先有鸡还是先有蛋的问题。如果在渲染之后才触发getPopupContainer
,那么useEffect
中就无法获取弹层内的节点:如果先行渲染
popup
,那么此时getPopupContainer
的 dom 则还没有 ready。现在做了如下改造,如果发现
getPopupContainer
没有triggerNode
参数,则同时触发。如果有则异步触发。因而缩小冲突范围,只有在即用了triggerNode
又使用popup[ref]
的场景下会变成延迟触发。ref https://codesandbox.io/s/eloquent-mclean-ss93m?file=/src/App.js