tabs icon indicating copy to clipboard operation
tabs copied to clipboard

Avoid using setTimeout in inkTabBarNode

Open picodoth opened this issue 7 years ago • 0 comments

in https://github.com/react-component/tabs/pull/134, we're doing a quick fix by using setTimeout to calculate inkTabBarNode position after parent/root node mounted.

The source reason is that InkTabBarNode needs to do a offset calculation upon componentDidMount based on parent/root node ref. In the original mixin approach, componentDidMount is shared between multiple mixin and can be executed in sequence, but the new composite approach has nested component structure and following React lifecycle sequence:

parent render => children render => children mounted => parent mounted...

So strictly speaking, we have to delay children render in every possible parent of inkTabBarNode. As a quick fix, we did a awkward setTimeout in inkTabBarNode's componentDidMount method to achieve the same purpose.

In fact, the ideal fix was tried here, but apparently more work needs to do https://github.com/react-component/tabs/commit/f019ea098c27df4ebcd7c3cf8a64494fe81c3685#diff-ad3456d46a980c23853783634a1555a7R37

picodoth avatar Aug 06 '18 03:08 picodoth