You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have noticed that a react component "with data" obtained by calling graphql(query)(component) doesn't work with HMR. Is this a known issue?
Failing Example
Any change to the SampleComponent (e.g. modifying text in the <p> element) isn't reflected in in HMR (I can se the module gets updated but browser doesn't render it).
classSampleComponentextendsReact.Component{render(){letemail='n/a'if(this.props.data.launch_contact){email=this.props.data.launch_contact.email}return(<div><p>Email is '{email}'.</p></div>)}}constMyQuery=gql`query MyQuery { launch_contact(id: 2) { email }}`constSampleComponentWithData=graphql(MyQuery)(SampleComponent)...classTopLevelComponentextendsReact.Component{render(){return(<ApolloProviderclient={client}><SampleComponentWithData/></ApolloProvider>)}}
Working Example
If I wrap SampleComponentWithData within another component the HMR work.
...
classWrapperComponentextendsReact.Component{render(){return(<div><SampleComponentWithData/><p>Any update here gets hot-reloaded correctly!</p></div>)}}classTopLevelComponentextendsReact.Component{render(){return(<ApolloProviderclient={client}><WrapperComponent/></ApolloProvider>)}}
HMR also works if I use SampleComponent directly (without Apollo query).
The text was updated successfully, but these errors were encountered:
Either way, this should in in react-apollo because it probably has to do with that integration. Thanks for providing a detailed discussion, let's keep talking there.
I have noticed that a react component "with data" obtained by calling
graphql(query)(component)
doesn't work with HMR. Is this a known issue?Failing Example
Any change to the
SampleComponent
(e.g. modifying text in the<p>
element) isn't reflected in in HMR (I can se the module gets updated but browser doesn't render it).Working Example
If I wrap
SampleComponentWithData
within another component the HMR work.HMR also works if I use
SampleComponent
directly (without Apollo query).The text was updated successfully, but these errors were encountered: