File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -390,7 +390,7 @@ export default function connectAdvanced(
390
390
props ,
391
391
ref
392
392
) {
393
- return < Connect wrapperProps = { props } forwardedRef = { ref } />
393
+ return < Connect { ... props } forwardedRef = { ref } />
394
394
} )
395
395
396
396
forwarded . displayName = displayName
Original file line number Diff line number Diff line change @@ -1796,6 +1796,48 @@ describe('React', () => {
1796
1796
done ( )
1797
1797
} )
1798
1798
1799
+
1800
+
1801
+ it ( 'should correctly separate and pass through props to the wrapped component with a forwarded ref' , async done => {
1802
+ const store = createStore ( ( ) => ( { } ) )
1803
+
1804
+ class Container extends Component {
1805
+ render ( ) {
1806
+ return < Passthrough { ...this . props } />
1807
+ }
1808
+ }
1809
+
1810
+ const decorator = connect (
1811
+ state => state ,
1812
+ null ,
1813
+ null ,
1814
+ { forwardRef : true }
1815
+ )
1816
+ const Decorated = decorator ( Container )
1817
+
1818
+ const ref = React . createRef ( )
1819
+
1820
+ class Wrapper extends Component {
1821
+ render ( ) {
1822
+ // The 'a' prop should eventually be passed to the wrapped component individually,
1823
+ // not sent through as `wrapperProps={ {a : 42} }`
1824
+ return < Decorated ref = { ref } a = { 42 } />
1825
+ }
1826
+ }
1827
+
1828
+ const tester = rtl . render (
1829
+ < ProviderMock store = { store } >
1830
+ < Wrapper />
1831
+ </ ProviderMock >
1832
+ )
1833
+
1834
+ tester . debug ( )
1835
+ await rtl . waitForElement ( ( ) => tester . getByTestId ( 'a' ) )
1836
+ expect ( tester . getByTestId ( 'a' ) ) . toHaveTextContent ( '42' )
1837
+
1838
+ done ( )
1839
+ } )
1840
+
1799
1841
it ( 'should return the instance of the wrapped component for use in calling child methods, impure component' , async done => {
1800
1842
const store = createStore ( ( ) => ( { } ) )
1801
1843
You can’t perform that action at this time.
0 commit comments