Skip to content

Umbrella: New Life-Cycles Ideas #7678

@sebmarkbage

Description

@sebmarkbage

I'll use this gather a few ideas of new life-cycle methods that help avoid existing problematic cases when using Fiber or other async rendering solutions.

  • componentDidServerRender: Gets called after the entire tree has rendered on the server. Useful for aborting buffered renders, or logging. Got the idea from Deprecate componentWillMount Maybe? #7671. This could possibly replace componentWillMount.
  • componentWasMounted and componentWasUpdated: Similar to componentDidMount and componentDidUpdate but happens asynchronously in spare cycles after a component has already appeared on the screen. That way triggering things like I/O doesn't have to block the component from rendering on the screen and dropping frames since componentDidMount have to be synchronous. This is not appropriate to use for Flux store subscriptions since you may be missing events that way. However, we can use "lazy subscriptions" as an alternative solution. componentWasMounted/componentWasUpdated (formerly componentDidDisplay) #5053.
  • componentWasUnmounted: Similar to the above, this would happen in spare cycles for clean up purposes where clean up is not synchronously needed. This may not be needed as a separate life-cycles since we can possibly just make componentWillUnmount async. Defer Execution of Unmount Life Cycle Hooks #6003.
  • componentWillMountNow and componentWillUpdateNow: This would be a fiber specific thing. Unlike the current componentWillMount / componentWillUpdate it actually happens after render and after all the children's render have been called, but right before any side-effects are committed to the DOM. The use case of reading the current scroll position in componentWillUpdate only to reset it later doesn't work with async rendering because you can scroll between componentWillUpdate and componentDidUpdate. This could possibly replace componentWillUpdate.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions