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

Upgrade dev dependency to react-redux v7 #4431

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

erikras
Copy link
Member

@erikras erikras commented Apr 10, 2019

This breaks a lot of the tests, and I'm not certain why. Many of the redux-form tests focus on how many times stuff gets rerendered, and something about that has changed with react-redux@7.

🤔

@markerikson
Copy link

That's... odd.

I would have expected the number of re-renders to be pretty consistent between v6 and v7. The number of times mapState is called would likely have changed, but actual re-renders shouldn't (much).

@vincentjames501
Copy link

Thanks for your continued work on this @erikras , many people still love and rely on Redux-Form!

@josepot
Copy link

josepot commented Apr 12, 2019

Hi!

I have been debugging this a bit and I think that I know what one of the issues is (quite possibly the main issue). I think that I have some ideas on how to fix it, but it's getting late and I want to go to bed. So, I will keep looking at this in another moment.

In the meanwhile, I will explain here what I have found, in case someone else wants to have a look at it before I get back to it:

The issue that I have found is that when a Field registers itself to the reduxForm a dispatch takes place (this.props.registerField(name, type)). However, when that dispatch happens, there are no listeners registered into the store yet 😮

@markerikson
Copy link

When exactly in the component lifecycle is that action being dispatched?

One thing that did change in v7 is that we're subscribing in a useEffect(), which will run just a bit async after the component is ready. In v5, we subscribed in componentDidMount (which is equivalent to useLayoutEffect()).

@josepot
Copy link

josepot commented Apr 12, 2019

Oh, ok, thanks @markerikson !

So, let me describe in more detail what I'm seeing:

node --inspect-brk node_modules/.bin/jest --runInBand -t 'should be `false` when `errors` has a `string` property'
  • In the previous commit, where all the tests are passing, this line gets evaluated 4 times for that test. Each time with a different state.

  • In the latest commit that line only gets evaluated once, with the initial state.

  • I can see that there is a dispatch that gets triggered and that dispatch has no listeners... However, later on, this line of react-redux takes care of that. That's cool 😄

  • Unfortunately, if I place a debugger here. I don't see that selector being evaluated after that. 🤔 😕

@josepot
Copy link

josepot commented Apr 12, 2019

Dah! Bingo! I found the issue! It's a problem with react-redux... I will create a fix and send a PR! (It seems that I won't get any sleep tonight 😄 )

Sorry, I was wrong... However, I found something interesting/weird:

For this test, the following line of connectAdvanced is never evaluated... The useEffect gets registered, but its content is never evaluated... It's like saying that the componentDidMount of the Connect component never happens. Therefore, the subscription.trySubscribe() of the Connected component never takes place... That's why there is no one listening when this happens. 😕

I know that sounds like non-sense, because the componentDidMount of the Provider does happen... But if you try to debug it, you will see that the only component that calls trySubscribe is the Provider... 😕

@josepot
Copy link

josepot commented Apr 12, 2019

More interesting stuff, check this out..

That sandbox does the exact same thing that this test does. However, in the sandbox App the output is the correct one.

That makes me think that the problem probably has to do with the way that the tests are being setup. Either that, or perhaps there is an issue with react-dom/test-utils.

@mikkom
Copy link

mikkom commented Apr 12, 2019

I think we should add calls to TestUtils.act in order to flush the effects in the tested components.

See for example this commit in a hook version of react-redux-promise-listener: mikkom/react-redux-promise-listener-hook@eebee1e

@erikras
Copy link
Member Author

erikras commented Apr 15, 2019

Thanks for your effort on this, guys.

@codecov-io
Copy link

codecov-io commented Jul 12, 2019

Codecov Report

Merging #4431 into master will decrease coverage by 99.47%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #4431       +/-   ##
==========================================
- Coverage   99.47%   0.00%   -99.48%     
==========================================
  Files          74      74               
  Lines        1728    1687       -41     
==========================================
- Hits         1719       0     -1719     
- Misses          9    1687     +1678     
Impacted Files Coverage Δ
src/Form.js 0.00% <0.00%> (-100.00%) ⬇️
src/index.js 0.00% <0.00%> (-100.00%) ⬇️
src/actions.js 0.00% <0.00%> (-100.00%) ⬇️
src/FormName.js 0.00% <0.00%> (-100.00%) ⬇️
src/hasError.js 0.00% <0.00%> (-100.00%) ⬇️
src/immutable.js 0.00% <0.00%> (-100.00%) ⬇️
src/propTypes.js 0.00% <0.00%> (-100.00%) ⬇️
src/FormSection.js 0.00% <0.00%> (-100.00%) ⬇️
src/actionTypes.js 0.00% <0.00%> (-100.00%) ⬇️
src/createField.js 0.00% <0.00%> (-100.00%) ⬇️
... and 64 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3e619a7...154cde4. Read the comment docs.

@renatoagds renatoagds added this to the v9.0.0 milestone Jul 30, 2019
@renatoagds renatoagds added enhancement improvements in current API next relating to next major release labels Jul 30, 2019
@renatoagds renatoagds removed this from the v9.0.0 milestone Oct 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement improvements in current API help wanted next relating to next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants