-
Notifications
You must be signed in to change notification settings - Fork 35
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 double re-render in LiftWrapper and migrate it to PureComponent #82
base: master
Are you sure you want to change the base?
Conversation
@KatSick benchmark results look awesome! thanks! @blacktaxi what do you think about those changes? Are we safe to merge it now, or you have any other objections? |
new RenderMany(this, newProps, n) // eslint-disable-line | ||
break | ||
setRenderCache(cache: RenderCache): void { | ||
if (this.renderCache === cache) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to check equality with !structEq(this.renderCache, cache)
as well? Just prevent rendering of the same state twice? This probably should be handled by React itself, but for some reason, we do that in the latest version. https://github.com/grammarly/focal/pull/82/files?diff=split&w=1#diff-71010d1ee0e73a76461ec411a47605c1207b1982317b93bd4fdc7c35fb7c6b1fL403
} | ||
// eslint-disable-next-line camelcase | ||
UNSAFE_componentWillMount() { | ||
this._subscribe(this.props) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to move subscribe
into constructor
to avoid dependency on legacy lifecycle?
In the article Update on async rendering React team provides two examples about pre-fetch and subscription.
When supporting server rendering, it’s currently necessary to provide the data synchronously – componentWillMount was often used for this purpose but the constructor can be used as a replacement.
The Adding event listener suggest to use componentDidMount
with initial value - it's not our case. But, they ok with using componentDidUpdate
instead of componentWillReceiveProps
@KatSick what do you think?
what was done:
LiftWrapper
to PureComponentLiftWrapper
logic to namespaceContext
todo before merge:
renderToStaticMarkup
is in unit-tests)Double re-render fix demo:
Screen.Recording.2021-07-26.at.11.19.14.mov