-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cead0a4
commit e675ca9
Showing
7 changed files
with
63 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# `.getWrappingComponent() => ReactWrapper` | ||
|
||
If a `wrappingComponent` was passed in `options`, this methods returns a `ReactWrapper` around the rendered `wrappingComponent`. This `ReactWrapper` can be used to update the `wrappingComponent`'s props, state, etc. | ||
|
||
|
||
#### Returns | ||
|
||
`ReactWrapper`: A `ReactWrapper` around the rendered `wrappingComponent` | ||
|
||
|
||
|
||
#### Examples | ||
|
||
```jsx | ||
import { Provider } from 'react-redux'; | ||
import { Router } from 'react-router'; | ||
import store from './my/app/store'; | ||
import mockStore from './my/app/mockStore'; | ||
|
||
function MyProvider(props) { | ||
const { children, customStore } = props; | ||
|
||
return ( | ||
<Provider store={customStore || store}> | ||
<Router> | ||
{children} | ||
</Router> | ||
</Provider> | ||
); | ||
} | ||
|
||
const wrapper = mount(<MyComponent />, { | ||
wrappingComponent: MyProvider, | ||
}); | ||
const provider = wrapper.getWrappingComponent(); | ||
provider.setProps({ customStore: mockStore }); | ||
wrapper.update(); // update root wrapper after wrappingComponent props changed | ||
``` | ||
|
||
|
||
|
||
#### Common Gotchas | ||
|
||
- Your root wrapper _will not_ automatically `update()` when the state/props of your `wrappingComponent` are changed. If you expect your component to render differently after calling `.setState()`/`.setProps()` on your `wrappingComponent`, you'll need to manually call `update()` on your root wrapper. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters