-
Notifications
You must be signed in to change notification settings - Fork 2k
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 React Redux and Redux Form #37438
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Webpack Runtime (~44 bytes added 📈 [gzipped])
Webpack runtime for loading modules. It is included in the HTML page as an inline script. Is downloaded and parsed every time the app is loaded. App Entrypoints (~1050 bytes added 📈 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Sections (~29547 bytes added 📈 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~14828 bytes added 📈 [gzipped])
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
Oh, I thought we were trying to drop Enzyme as a dependency and rewriting things with ReactDOM test utils wherever possible? |
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.
Code-wise, this LGTM. Left some very minor comments. Will try to run some tests now.
@@ -1,12 +1,14 @@ | |||
/** | |||
* @module templates/index | |||
* External dependencies |
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.
Are the changes in this file related to this PR? I'm ok with keeping them, but I just want to make sure.
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.
Some changes are ESLint fixes, this one related to missing internal/external docblock comments. And I also removed the @module
docblock pragma -- we don't use it anywhere else.
|
||
render() { | ||
return ( | ||
<ReactReduxContext.Consumer> |
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.
That's a clever, minimal fix, that doesn't entail too much rewriting 👍
export class JetpackConnectHelpButton extends PureComponent { | ||
static propTypes = { label: PropTypes.string }; | ||
export default function JetpackConnectHelpButton( { label } ) { | ||
const dispatch = useDispatch(); |
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.
\o/
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.
I played around with several things you touched in the live branch and couldn't find any issues 👍
The E2E tests should also add some measure of safety.
LGTM!
I'm not so sure about Enzyme tests that use the full React mount with JSDOM -- Enzyme's Some benefits of the Enzyme wrapper:
I don't want to go too deep into the React testing debate, as I have limited knowledge and no strong opinions about it. I mainly wanted to fix the tests that got broken during the |
…e the component React Redux ref API has changed in 7.0.0. Modernization includes: - use modern refs - use arrow functions for bound methods - every variable has its own `const` decl
…nzyme option Instead of using the legacy React context, which is an implementation detail of particular React Redux version, use the Enzyme's `wrappingComponent` option to render a mock Redux provider above the tested component.
…omponent, use full mount React Redux 7.x no longer supports `store` prop for `Provider`, and uses the new `React.createContext()` instead of the legacy context. That requires an update of the unit tests. - use `wrappingComponent` option to activate a mock Redux provider - switch to full mount, as `wrappingComponent` doesn't work with `useContext` in Enzyme (enzymejs/enzyme#2176)
53d88e1
to
9cd1aef
Compare
Sounds good to me 👍 Sorry if I derailed the conversation, but I was curious 🙂 |
Renovate bot keeps force-pushing over my changes in #32129, so I'm creating a new PR with all the human interventions that are needed.
This will be a tough upgrade, as there are two breaking changes:
Refs to connected components:
connect
used to requirewithRef: true
flag if a ref was expected to be forwarded to the inner component. If it wasn't present, the ref would be assigned the outer, connected component.In v7, the
withRef
flag was renamed toforwardRef
. That's not hard to change. But there's additional gotcha: ifforwardRef
is not present, the ref passed to the outer component will be ignored. It will not be set to anything, not even the outer component. That can cause subtle issues that can be discovered only by manual testing.I needed to change the following components:
canvas
element.withRef
: things were silently failing.No
store
in legacy React context:At several places, we extract the
store
from legacy React context (definingcontextTypes
and usingthis.context
. This no longer works, becausestore
is now in new React context (with provider and consumer components).The following places need to be updated:
RootChild
component that transfers the context to a different React mount treeTests:
I also needed to update a few tests that used
react-dom/test-utils
, because they started failing for some reason with the newreact-redux
. I ended up rewriting them with Enzyme, its full mount capability and the easy-to-use component wrappers. With hindsight, all that was needed was probably wrapping the renders withact( ... )
, but I think that the Enzyme rewrite is still definitely a clear step forward.