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

Use new Context, forwardRef for 6.x (alternate implementation to #995) #997

Closed
wants to merge 30 commits into from

Commits on Jul 14, 2018

  1. fix connected props derived props generation

    This commit fixes reduxjs#965
    
    The essence of the problem is that getDerivedStateFromProps is called when the incoming props OR incoming local state changes. So we cannot store anything in state that is needed in shouldComponentUpdate.
    
    This commit splits up the tracking of incoming props, incoming store state changes, and removes getDerivedStateFromProps and the usage of local state to store any information.
    
    Instead, local state is used as a flag solely to track whether the incoming store state has changed.
    
    Since derived props are needed in shouldComponentUpdate, it is generated there and then compared to the previous version of derived props.
    
    If forceUpdate() is called, this bypasses sCU, and so a check in render() compares the props that should have been passed to sCU to those passed to render(). If they are different, it generates them just-in-time.
    
    To summarize:
    1) shouldComponentUpdate is ONLY used to process changes to incoming props
    2) runUpdater (renamed to triggerUpdateOnStoreStateChange) checks to see if the store state has changed, and stores the state, then updates the counter in local state in order to trigger a new sCU call to re-generate derived state.
    
    Because of these changes, getDerivedStateFromProps and the polyfill are both removed.
    
    All tests pass on my machine, but there is at least 1 side effects to the new design:
    
     - Many of the tests pass state unchanged to props, and pass this to child components. With these changes, the two updates are processed separately. Props changes are processed first, and then state changes are processed.
    
    I updated the affected tests to show that there are "in-between" states where the state and props are inconsistent and mapStateToProps is called with these changes. If the old behavior is desired, that would require another redesign, I suspect.
    cellog committed Jul 14, 2018
    Copy the full SHA
    aaa0470 View commit details
    Browse the repository at this point in the history
  2. fix linting errors

    cellog committed Jul 14, 2018
    Copy the full SHA
    41ff984 View commit details
    Browse the repository at this point in the history

Commits on Jul 16, 2018

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

Commits on Aug 11, 2018

  1. Merge pull request #3 from reduxjs/master

    merge in testing
    cellog committed Aug 11, 2018
    Copy the full SHA
    865cc82 View commit details
    Browse the repository at this point in the history

Commits on Aug 12, 2018

  1. Copy the full SHA
    eaa3284 View commit details
    Browse the repository at this point in the history
  2. add wallaby.js for debugging using wallaby

    DO NOT REMOVE PLEASE TIM
    cellog committed Aug 12, 2018
    Copy the full SHA
    499aa63 View commit details
    Browse the repository at this point in the history
  3. Copy the full SHA
    0e2e194 View commit details
    Browse the repository at this point in the history
  4. convert more tests to rtl

    cellog committed Aug 12, 2018
    Copy the full SHA
    1e0ad89 View commit details
    Browse the repository at this point in the history
  5. Copy the full SHA
    545f53d View commit details
    Browse the repository at this point in the history
  6. fix error in test

    cellog committed Aug 12, 2018
    Copy the full SHA
    5333b40 View commit details
    Browse the repository at this point in the history
  7. convert to rtl

    cellog committed Aug 12, 2018
    Copy the full SHA
    a47b64c View commit details
    Browse the repository at this point in the history
  8. update testing infrastructure

    cellog committed Aug 12, 2018
    Copy the full SHA
    77d4fa3 View commit details
    Browse the repository at this point in the history
  9. Copy the full SHA
    0f427b5 View commit details
    Browse the repository at this point in the history
  10. fix lint errors

    cellog committed Aug 12, 2018
    Copy the full SHA
    b255a46 View commit details
    Browse the repository at this point in the history
  11. Copy the full SHA
    eb960c4 View commit details
    Browse the repository at this point in the history
  12. Merge pull request #4 from cellog/master

    merge new rtl tests and test framework
    cellog committed Aug 12, 2018
    Copy the full SHA
    f0e01b3 View commit details
    Browse the repository at this point in the history
  13. almost fully working 16.4-context-based

    passing store in props and hot update are only failing tests
    cellog committed Aug 12, 2018
    Copy the full SHA
    79d5bbb View commit details
    Browse the repository at this point in the history
  14. Copy the full SHA
    70837a4 View commit details
    Browse the repository at this point in the history
  15. fix custom store subscription

    this allows multiple concurrent react-redux subscriptions in the same component tree, using two root providers.
    
    By creating a custom context and passing that to the Provider and to connected components that use it, we get the full benefits of subscriptions with 2 different trees.
    cellog committed Aug 12, 2018
    Copy the full SHA
    f6bb7b9 View commit details
    Browse the repository at this point in the history

Commits on Aug 13, 2018

  1. fully working. Implement forwardRef

    * remove hot reloading test, this is unnecessary now because Provider handles subscription through React context, and updates store subscription on componentDidUpdate
    * remove ProviderMock, it is just Provider now, in connect.spec.js
    * remove ReduxConsumer, Connect is now ReduxConsumer
    * error out if withRef is passed, users are expected to use forwardRef now
    * connect now allows passing in forwardRef() elements too through react-is
    cellog committed Aug 13, 2018
    Copy the full SHA
    5284a5d View commit details
    Browse the repository at this point in the history
  2. fix linting errors, remove createProvider

    * createProvider is no longer necessary, because it is replaced by passing in context provider to Provider and consumer to connected components. Also, nested providers is natively supported in React
    cellog committed Aug 13, 2018
    Copy the full SHA
    5dba595 View commit details
    Browse the repository at this point in the history
  3. Copy the full SHA
    944deb6 View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    3e95c17 View commit details
    Browse the repository at this point in the history
  5. Copy the full SHA
    c7a39e4 View commit details
    Browse the repository at this point in the history
  6. update incorrect test, and fix updating store in props for Provider

    This refactor also lifts the "value" up into state for Provider, which is simpler. The bug was that componentDidUpdate was using nextProps instead of lastProps. Switching the state setting to use this.props was the correct behavior
    cellog committed Aug 13, 2018
    Copy the full SHA
    64078ee View commit details
    Browse the repository at this point in the history
  7. Copy the full SHA
    e2f78f0 View commit details
    Browse the repository at this point in the history
  8. fix rollup build

    cellog committed Aug 13, 2018
    Copy the full SHA
    92f5e31 View commit details
    Browse the repository at this point in the history
  9. fix lint error

    cellog committed Aug 13, 2018
    Copy the full SHA
    a78e6d5 View commit details
    Browse the repository at this point in the history
  10. Copy the full SHA
    5b4b201 View commit details
    Browse the repository at this point in the history

Commits on Aug 14, 2018

  1. performance enhancements

    cellog committed Aug 14, 2018
    Copy the full SHA
    1ba4924 View commit details
    Browse the repository at this point in the history