Giter Club home page Giter Club logo

Comments (9)

gaearon avatar gaearon commented on May 18, 2024 2

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.

from react-transform-hmr.

idris avatar idris commented on May 18, 2024

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

from react-transform-hmr.

gaearon avatar gaearon commented on May 18, 2024

Please create a minimal reproducing example.

from react-transform-hmr.

idris avatar idris commented on May 18, 2024

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.

from react-transform-hmr.

skosch avatar skosch commented on May 18, 2024

@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 :)

from react-transform-hmr.

gaearon avatar gaearon commented on May 18, 2024

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.

from react-transform-hmr.

laszbalo avatar laszbalo commented on May 18, 2024

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';

from react-transform-hmr.

skosch avatar skosch commented on May 18, 2024

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

from react-transform-hmr.

laszbalo avatar laszbalo commented on May 18, 2024

@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.

from react-transform-hmr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.