Closed spacemeowx2 closed 5 years ago
I wrote this test case:
it('should pass the correct value after changing the context value', () => { const ctx = createContext('foo') let doSetState = null let actual class Children extends Component { render () { actual = this.context return <div>bar</div> } } Children.contextType = ctx const Provider = ctx.Provider class App extends Component { constructor () { super(...arguments) this.state = { value: 'bar' } } componentDidMount () { doSetState = (value) => { this.setState({ value }) } } render () { return <Provider value={this.state.value}> <Children /> </Provider> } } render(<App />, scratch) expect(actual).toEqual('bar') doSetState('bob') rerender() expect(actual).toEqual('bob') })
Test result:
Expected value to equal: "bob" Received: {"__context_11__": {"handlers": [], "value": "bob"}}
It’s very helpful to me
thx.
It's been awhile. Can we release a new patch version for this?
I wrote this test case:
Test result: