Skip to content
This repository has been archived by the owner on Apr 9, 2020. It is now read-only.

Hot loading doesn't work when using Relay #22

Closed
idris opened this issue Oct 19, 2015 · 9 comments
Closed

Hot loading doesn't work when using Relay #22

idris opened this issue Oct 19, 2015 · 9 comments

Comments

@idris
Copy link

idris commented Oct 19, 2015

(issue moved from gaearon/babel-plugin-react-transform#39)
Since I started using Relay, hot loading always gives the error

[HMR] The following modules couldn't be hot updated: (They would need a full reload!)

The issue is also mentioned in fortruce/relay-skeleton#1, but I don't think that solution is a good way to go.

@idris
Copy link
Author

idris commented Oct 19, 2015

My project is closed-source, so I can't share the code. Maybe I'll try to whip up an example

@gaearon
Copy link
Owner

gaearon commented Oct 19, 2015

Please create a minimal reproducing example.

@idris
Copy link
Author

idris commented Oct 19, 2015

Okay, I got it working.. the problem in my case was that I was specifying the query.plugins with babelRelayPlugin in webpack. As soon as I moved that to my .babelrc, everything worked fine.

I'll let you know if I run into anything else, but for now I'm closing this.

@idris idris closed this as completed Oct 19, 2015
@skosch
Copy link

skosch commented Apr 12, 2016

@gaearon I seem to have the same problem. fortruce/relay-skeleton#1 seems to suggest that hot reload works only for exported components, but not for exported Relay containers wrapping the former. Is that the case? And if so, do you have any suggestions on how to deal with that? Thank you :)

@gaearon
Copy link
Owner

gaearon commented Apr 13, 2016

I don't have a good solution right now. Hopefully we'll have something that detects any kind of component by the end of this year.

@laszbalo
Copy link

laszbalo commented May 2, 2016

App.js:

export class AppComponent extends Component {
  render() {
    return <h1>Plain Old React Component</h1>
  }
}

const App = Relay.createContainer(AppComponent, {...});

export default App;

index.js:

import App, {AppComponent} from './App';

I am using the above pattern. HMR works like a charm.

Of course, when working with Relay, this would suffice:

import App from './App';

Without Relay, in a normal Ract app, I'd write this:

import {AppComponent} from './App';

@gaearon
Copy link
Owner

gaearon commented May 2, 2016

I don't have a good solution right now. Hopefully we'll have something that detects any kind of component by the end of this year.

Actually, I do have a solution now: gaearon/react-hot-boilerplate#61. Not sure whether it works with Relay, but I don’t see why not.

@skosch
Copy link

skosch commented May 2, 2016

@laszbalo that works indeed, very clever (except that I now get annoying linter warnings about the unused import) – looking forward to v3 though!

@laszbalo
Copy link

laszbalo commented May 3, 2016

@skosch in the above example that App module exports two things:

  1. AppComponent; named export, just a plain React component
  2. App; default export, a Relay-powered React component

If you are using Relay, you probably want to import only the App component from the App module. Hence there should be no linter warnings.
If your project does note use Relay, you only want to import AppComponent component from the App module.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants