Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update hot-reload example to use require() #304

Closed
wants to merge 1 commit into from

Conversation

grrowl
Copy link

@grrowl grrowl commented Nov 6, 2016

This was the only way I could get it to work, migrating from webpack 1 on a fairly simple project.

Also, seems logical since you either need to render the new reference to App, or re-require it on every render call (see gaearon/react-hot-loader#243 (comment))

This was the only way I could get it to work, migrating from webpack 1 on a fairly simple project.

Also, seems logical since you either need to render the new reference to App, or re-require it on every `render` call 
(see gaearon/react-hot-loader#243 (comment))
@jsf-clabot
Copy link

jsf-clabot commented Nov 6, 2016

CLA assistant check
All committers have signed the CLA.

@SpaceK33z
Copy link
Member

@jmreidy, can you confirm this?

const render = () => {
ReactDOM.render(
<AppContainer>
<App/>
{ require('./components/App').default }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the code will be more clear if we did not inline it:

  const App = require('./components/App').default
  ReactDOM.render(
    <AppContainer>
      <App />

Also, require('./components/App').default results in a React Component instead of a React Element, so I believe it doesn’t work unless you change it to this:

      {React.createElement(require('./components/App').default)}

@sokra
Copy link
Member

sokra commented Nov 6, 2016

In webpack 2 it should work with import as the accept updates the bindings.

If it doesn't work this way, it's a webpack bug.

@sokra sokra closed this Nov 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants