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

Nested stateless components do not hot reload #8465

Closed
nickjanssen opened this issue Jun 28, 2016 · 24 comments
Closed

Nested stateless components do not hot reload #8465

nickjanssen opened this issue Jun 28, 2016 · 24 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@nickjanssen
Copy link

nickjanssen commented Jun 28, 2016

  • Provide a minimal code snippet / rnplay example that reproduces the bug.
import React, { Component } from 'react';
import {
  AppRegistry,
  View,
  Text
} from 'react-native';

const ThisWillNotHotReload = () => {
  return (
    <Text>If change this text, it will not hot reload.</Text>
  )
}

const BugTest = () => {
  return (
    <View style={{
      flex: 1,
      justifyContent: 'center',
      alignItems: 'center'
    }}>
      <ThisWillNotHotReload />
    </View>
  )
}

AppRegistry.registerComponent('BugTest', () => BugTest);
  • Provide screenshots where appropriate

Stateless components:
hotreloadnotworking

Same but with a class:
hotreloadworking

  • What's the version of React Native you're using?

0.28.0

  • Does this occur on iOS, Android or both?

both

  • Are you using Mac, Linux or Windows?

Mac

@satya164
Copy link
Contributor

cc @martinbigio

@olegdeezus
Copy link

Have same issue

  • React Native version: 0.29.0
  • iOS
  • Mac

@przemyslaw-wlodek
Copy link

przemyslaw-wlodek commented Aug 23, 2016

  • React Native 0.31.0
  • Android
  • Linux

I don't even need to nest the components.

  • src/components/App/index.android.js
import React from 'react';
import {
  Text,
  View
} from 'react-native';

const App = () => (
  <View>
    <Text>
      Welcome to React Native!
    </Text>
  </View>
);

export default App;
  • index.android.js
import { AppRegistry } from 'react-native';
import App from './src/components/App';

AppRegistry.registerComponent('ReactNativeStarter', () => App);

@steida
Copy link

steida commented Sep 8, 2016

I think the trick is to have at least one ES6 component. Then it should work.

@khanghoang
Copy link

@steida could you elaborate you comment?

@khanghoang
Copy link

khanghoang commented Sep 10, 2016

@steida thanks. I tried but it doesn't work, i'm using react native ver 0.31

@steida
Copy link

steida commented Sep 10, 2016

It works in Este, so get an inspiration from it.

@nbaldwin
Copy link

Same issue on 0.33, stateless functional component doesn't hot reload, works with ES6 class syntax.

  • React Native version: 0.33.0
  • iOS
  • Mac

@zackify
Copy link

zackify commented Oct 5, 2016

This still happens for me too. in 0.34.1

@nakamorichi
Copy link

Any fix on the horizon? Been using hot reloadable stateless components in React vanilla for some time now, and wouldn't want to switch back to stateful components if there is no actual need.

@jamielob
Copy link

Same issue on 0.35.0, iOS simulator and device, Mac.

@jcady
Copy link

jcady commented Nov 10, 2016

Still an issue. 0.37.0 with iOS simulator on mac.

@sospedra
Copy link

+1 under v0.37

@kylealwyn
Copy link

+1 on 0.40

@GeeWee
Copy link

GeeWee commented Feb 5, 2017

+1

@sospedra
Copy link

sospedra commented Feb 6, 2017

Bump! +1 on v0.40
(Styling RN apps without HMR is a pain in the 💨 )

@comountainclimber
Copy link

Will this issue be resolved anytime in the near future?

@jettandres
Copy link

+1! still existing on 0.44.0

@hramos
Copy link
Contributor

hramos commented May 25, 2017

If you're still running into this, the best approach right now would be to send a PR with a fix. Please refrain from adding metoo comments so that we can keep the discussion focused on a fix.

@bvic23
Copy link

bvic23 commented Jul 26, 2017

Try my babel plugin https://github.com/bvic23/babel-plugin-functional-hmr until the issue is fixed.

@pull-bot
Copy link

pull-bot commented Oct 9, 2017

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

@hramos hramos added the Icebox label Oct 9, 2017
@hramos hramos closed this as completed Oct 9, 2017
@facebook facebook locked as resolved and limited conversation to collaborators Oct 9, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 9, 2018
@gaearon
Copy link
Collaborator

gaearon commented Jun 28, 2019

This has been fixed on master and should get into 0.61. #18899 (comment)

If you have more cases that don't work please post reproducing examples in #18899.

@gaearon
Copy link
Collaborator

gaearon commented Jun 29, 2019

(The only caveat is that for Fast Refresh to work, you'll need to move your root component to a separate file)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests