Skip to content
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 getDerivedStateFromProps usage #980

Closed
wants to merge 20 commits into from

Commits on Jul 21, 2018

  1. up min react versions

    cellog committed Jul 21, 2018
    Copy the full SHA
    b631441 View commit details
    Browse the repository at this point in the history
  2. working, except the issue with multiple mapState calls

    breaks 3 tests:
    
    connect.spec.js:
    1. React connect should subscribe properly when a middle connected component does not subscribe
    2. React connect should pass state consistently to mapState
    
    Provider.spec.js
    1. React should pass state consistently to mapState
    
    However, it is possible that the tests fail simply because the ORDER has changed? Will test that theory in a moment
    cellog committed Jul 21, 2018
    Copy the full SHA
    25e3fc6 View commit details
    Browse the repository at this point in the history
  3. typo

    cellog committed Jul 21, 2018
    Copy the full SHA
    de4e4f3 View commit details
    Browse the repository at this point in the history

Commits on Jul 22, 2018

  1. success! gDSFP-based react-redux

    The key is that in gDSFP we grab the current store state instead of using our cached value, and it always works, even with batched redux actions. We also use current props instead of cached ones in relevant portions.
    cellog committed Jul 22, 2018
    Copy the full SHA
    f751ac9 View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    9284894 View commit details
    Browse the repository at this point in the history
  3. remove debugging code

    cellog committed Jul 22, 2018
    Copy the full SHA
    948c20f View commit details
    Browse the repository at this point in the history

Commits on Jul 24, 2018

  1. use polyfill, make peer dependency relaxed

    Store last seen props in gDSFP (was an oversight). Does not change behavior, just performance.
    cellog committed Jul 24, 2018
    Copy the full SHA
    490b0e3 View commit details
    Browse the repository at this point in the history

Commits on Jul 25, 2018

  1. fix style details

    cellog committed Jul 25, 2018
    Copy the full SHA
    86e986b View commit details
    Browse the repository at this point in the history

Commits on Aug 1, 2018

  1. move instance props into state

    This does not make subscriptions async-safe, because redux uses the subscription to render children. This is an anti-pattern that will need to be fixed in 6.0 when a redesign using the new Context API is done
    cellog committed Aug 1, 2018
    Copy the full SHA
    1d96dac View commit details
    Browse the repository at this point in the history

Commits on Aug 2, 2018

  1. make subscription async-safe

    In redux 5 and earlier, subscription to the store is done in the constructor, and passed down to children. But in async, it is possible for a render tree to begin, then suspend, then be discarded. In this case, we leak memory from the subscription that was created.
    
    This new system postpones the creation of subscription until componentDidMount is called, which is when subscriptions are safe to be made. The principles are gleaned from this gist by bvaughn:
    
    https://gist.github.com/bvaughn/d569177d70b50b58bff69c3c4a5353f3
    cellog committed Aug 2, 2018
    Copy the full SHA
    26e4fb8 View commit details
    Browse the repository at this point in the history
  2. fully fix subscription

    async-safe Subscription now works as follows:
    * on element creation, a Subscription object is initialized, but does not link to anything outside of the current element
    * after the component tree is rendered, componentDidMount is called
    * This triggers hydration of the subscription tree, which is ready to subscribe
    * parent elements create their listener collection, and children subscribe cascading to the bottom of the element tree
    cellog committed Aug 2, 2018
    Copy the full SHA
    6b83e13 View commit details
    Browse the repository at this point in the history
  3. update subscription change check to be accurate

    This needs to check whether notifyNestedSubs has changed, not subscription, now that subscription is set in the constructor and only changes its internals when it is safe.
    cellog committed Aug 2, 2018
    Copy the full SHA
    8a8e151 View commit details
    Browse the repository at this point in the history

Commits on Aug 3, 2018

  1. rename resolves to be clearer

    cellog committed Aug 3, 2018
    Copy the full SHA
    52d4f45 View commit details
    Browse the repository at this point in the history
  2. resolve conflicts

    cellog committed Aug 3, 2018
    Copy the full SHA
    3333363 View commit details
    Browse the repository at this point in the history
  3. Copy the full SHA
    d50fb7d View commit details
    Browse the repository at this point in the history
  4. remove console statements

    cellog committed Aug 3, 2018
    Copy the full SHA
    1d8ab34 View commit details
    Browse the repository at this point in the history
  5. fix for React 16-16.3

    in order to handle subscriptions in state, we have to treat React 16.4 differently from 16.3, because state changes trigger gDSFP in 16.4 and don't in 16.3-
    cellog committed Aug 3, 2018
    Copy the full SHA
    fe60a4b View commit details
    Browse the repository at this point in the history
  6. fix breaking tests

    Also improves performance
    it seemed componentDidUpdate was needed to ensure subscriptions work, but this is untrue, and causes infinite loops on pre-React 16
    cellog committed Aug 3, 2018
    Copy the full SHA
    72fca1c View commit details
    Browse the repository at this point in the history
  7. Copy the full SHA
    1285e4e View commit details
    Browse the repository at this point in the history

Commits on Aug 4, 2018

  1. Copy the full SHA
    35e9d12 View commit details
    Browse the repository at this point in the history