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

Re-build stylesheets on hot reload #16

Closed
Kerumen opened this issue Jun 15, 2016 · 16 comments
Closed

Re-build stylesheets on hot reload #16

Kerumen opened this issue Jun 15, 2016 · 16 comments

Comments

@Kerumen
Copy link
Contributor

Kerumen commented Jun 15, 2016

Is it possible?

I tried the following but it's not working.

if (module.hot) {
  module.hot.accept(() => {
    EStyleSheet.build();
  });
}
@vitalets
Copy link
Owner

hi,
it should be possible after #7
What error message you are getting?

@Kerumen
Copy link
Contributor Author

Kerumen commented Jun 16, 2016

I don't have any error message. It's just not working silently.

@vitalets
Copy link
Owner

I think styles are re-calculated, but components are not re-rendered automatically (because EStyleSheet.build(); does not force re-render, it's just re-calculates styles).
Could you check it somehow? Maybe call forceUpdate() on some component after EStyleSheet.build() caused by hot reload?

@Kerumen
Copy link
Contributor Author

Kerumen commented Jun 17, 2016

Yup, you were right. Any ideas about how can I force the rerender ?
I can't put a forceUpdate in each component..

@vitalets
Copy link
Owner

Agree. It's not the solution to manually update components.
Currently i'm working on re-render components on orientation change #9 and in fact it is the same task.
I think we will wrap top components into mixin that will keep them update on an style changes (no matter it was hot reload or orientation change)
So waiting for #9 here..

@Kerumen
Copy link
Contributor Author

Kerumen commented Jun 17, 2016

Okey I will watch #9, thanks :)

@Kerumen Kerumen closed this as completed Jun 17, 2016
@gastonmorixe
Copy link

Any updates on this? I have styles.js file and it is not updating on hot reload.

@vitalets
Copy link
Owner

vitalets commented Aug 7, 2017

@gastonmorixe Could you provide a simple snippet demonstrating it?

@alvinwoon
Copy link

+1. HMR is broken for some reason. Using it via Expo tho.

@vitalets
Copy link
Owner

I'll keep this open to not forget about hot reload.

@vitalets vitalets reopened this Sep 29, 2017
vitalets pushed a commit that referenced this issue Nov 1, 2017
@vitalets
Copy link
Owner

vitalets commented Nov 1, 2017

Released support of HMR in 0.8.0. Also added a docs section.
Feel free to reopen in case of any issues.

@vitalets vitalets closed this as completed Nov 1, 2017
@corysimmons
Copy link

@vitalets Non-support for HMR is still mentioned in README under caveats. https://github.com/vitalets/react-native-extended-stylesheet#caveats

If you're happy with 0.8+ implementation of it, can we remove that warning from README?

@gastonmorixe
Copy link

is HMR working when styles are in a external file? It's not working for me (in React Native 0.53)

@vitalets
Copy link
Owner

@gastonmorixe Could you show some demonstrating code if possible?

@joelgetaction
Copy link

NOTE: This code:

module.hot.accept(() => {
	      EStyleSheet.clearCache();
	      EStyleSheet.build(); // force style re-calculation
	    });

will crash release builds instantly on launch that are uploaded and distributed via TestFlight, so be sure to exclude it from your release builds.

@vitalets
Copy link
Owner

@joelgetaction Could you show the crash trace?

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

No branches or pull requests

6 participants