Intended outcome:
I am storing query variables inside the React 16.3 context, and passing them to my Query component. This works as expected on the client side, but when rendering on the server side, getDataFromTree does not update the context value.
Actual outcome:
The context value is never updated, the default set at the start is used everywhere
How to reproduce the issue:
import * as React from 'react';
import { getDataFromTree } from 'react-apollo';
const TestContext = React.createContext({ test: 'defaultValueSetByHardcode' });
const TestChildren = () => {
return (
<TestContext.Consumer>
{({ test }) => {
console.log('Consume value in TestChildren', { test });
return (<pre>{ test }</pre>);
}}
</TestContext.Consumer>
);
};
const TestParent = () => {
console.log('Rendering TestParent, providing test = valueSetByProvider ')
return (
<TestContext.Provider value={{ test: 'valueSetByProvider'}}>
<TestChildren/>
</TestContext.Provider>
);
};
getDataFromTree(<TestParent/>, {}).then(() => {
console.log('Getting data does not update the context');
});
Running that will log to the terminal the following lines:
Rendering TestParent, providing test = valueSetByProvider
Consume value in TestChildren { test: 'defaultValueSetByHardcode' }
Getting data does not update the context
Version
Is this really fixed? Still experiencing the same issues.
Most helpful comment
Is this really fixed? Still experiencing the same issues.