diff --git a/fixtures/nesting/package.json b/fixtures/nesting/package.json
index 3a5a893714ec4..130ecfa54e772 100644
--- a/fixtures/nesting/package.json
+++ b/fixtures/nesting/package.json
@@ -3,7 +3,8 @@
"version": "0.1.0",
"private": true,
"dependencies": {
- "react-scripts": "3.4.1"
+ "react-scripts": "3.4.1",
+ "redux": "^4.0.5"
},
"scripts": {
"postinstall": "run-p install:*",
diff --git a/fixtures/nesting/src/legacy/Greeting.js b/fixtures/nesting/src/legacy/Greeting.js
index b06ea7c9cc805..706e1b23ee7dc 100644
--- a/fixtures/nesting/src/legacy/Greeting.js
+++ b/fixtures/nesting/src/legacy/Greeting.js
@@ -2,10 +2,12 @@ import React from 'react';
import {Component} from 'react';
import {findDOMNode} from 'react-dom';
import {Link} from 'react-router-dom';
+import {connect} from 'react-redux';
+
import ThemeContext from './shared/ThemeContext';
import Clock from './shared/Clock';
-export default class AboutSection extends Component {
+class AboutSection extends Component {
static contextType = ThemeContext;
componentDidMount() {
@@ -23,6 +25,13 @@ export default class AboutSection extends Component {
This component is rendered by the nested React.
+ Counter: {this.props.counter} + {' '} + +
Go to Home @@ -30,3 +39,10 @@ export default class AboutSection extends Component { ); } } + + +function mapStateToProps(state) { + return { counter: state }; +} + +export default connect(mapStateToProps)(AboutSection); diff --git a/fixtures/nesting/src/legacy/createLegacyRoot.js b/fixtures/nesting/src/legacy/createLegacyRoot.js index 982308756647d..3c5bb6787ac31 100644 --- a/fixtures/nesting/src/legacy/createLegacyRoot.js +++ b/fixtures/nesting/src/legacy/createLegacyRoot.js @@ -7,6 +7,7 @@ import ThemeContext from './shared/ThemeContext'; // Note: this is a semi-private API, but it's ok to use it // if we never inspect the values, and only pass them through. import {__RouterContext} from 'react-router'; +import {ReactReduxContext} from 'react-redux'; // Pass through every context required by this tree. // The context object is populated in src/modern/withLegacyRoot. @@ -14,7 +15,9 @@ function Bridge({children, context}) { return (+ Counter: {counter} + {' '} + +
> ); } + +function mapStateToProps(state) { + return { counter: state }; +} + +export default connect(mapStateToProps)(AboutPage); diff --git a/fixtures/nesting/src/modern/HomePage.js b/fixtures/nesting/src/modern/HomePage.js index 43ab3bfe83351..13073e4acb6d8 100644 --- a/fixtures/nesting/src/modern/HomePage.js +++ b/fixtures/nesting/src/modern/HomePage.js @@ -5,7 +5,7 @@ import {Link} from 'react-router-dom'; import ThemeContext from './shared/ThemeContext'; import Clock from './shared/Clock'; -export default function HomePage() { +export default function HomePage({ counter, dispatch }) { const theme = useContext(ThemeContext); return ( <> diff --git a/fixtures/nesting/src/modern/index.js b/fixtures/nesting/src/modern/index.js index 17021479a4e54..940886e9bbaf2 100644 --- a/fixtures/nesting/src/modern/index.js +++ b/fixtures/nesting/src/modern/index.js @@ -1,11 +1,15 @@ import React from 'react'; import {StrictMode} from 'react'; import ReactDOM from 'react-dom'; +import {Provider} from 'react-redux'; import App from './App'; +import {store} from '../store'; ReactDOM.render(