-
Notifications
You must be signed in to change notification settings - Fork 3
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
Few Questions #2
Comments
Hi @HenriBeck thanks for reviewing! 🙂
|
Can't we use the reference to the InnerComponent? The component should only ever be wrapped once and the reference doesn't change when an HMR updates the pages, right? |
Mb we should rewrite injectSheet in a way that allows implementing HMR from the outside without making injectSheet implement specific logic for HMR, but instead more generic stuff. Since injectSheet hoc is all about managing side effects of CSS, maybe we need to abstract away the side effects and allow some control of those from the outside. Basically we need to provide a couple of hooks which can be passed over props from the HOC and receive required references. Those hooks could be non-documented, so we don't bloat the public api surface, but we could still clearly separate those components @felthy can you make a suggestion here about what hooks would you need and what arguments should they receive? |
I think we would just need a way to update the state when the props change? So may a function which will return whether or not to update the sheets? And in |
One more reason to keep HMR logic in a separate module: after all you might not need it soon or it might be much simpler https://twitter.com/dan_abramov/status/1016994041823498241 |
The reference to the InnerComponent didn't work. I think that's because it is passed in prior to being wrapped, but it's pretty hard to understand what's going on to be honest. The HOC itself gets proxied by react-hot-loader as well though, so I can use @kof I'm still thinking about how to separate this properly, it's pretty hard to reason about though. I haven't given up! |
@felthy chat with me on gitter or twitter if you want to talk about it faster |
I think we might need something like |
@HenriBeck what do you mean exactly? |
Also wanted to throw in the way So to sum up: The
|
I found out about this issue: gaearon/react-hot-loader#1024 Mb we should just keep it that way as it is right now and not reinvest into HMR at all |
That’s intriguing ... but a year is a long time! Personally, I wouldn’t care much about HMR if it wasn’t for JSS - JSS is the only place where I want (need?) it. The kind of work I do is pretty heavy on the CSS, and building styles from scratch with Having said that, I do agree that keeping this the way it is (i.e. not rearchitecting |
Are you really relying on the current state or you just need the webpack hot reload? |
Yeah and also evtl its good to have that hmr issue linked for people thinking hmr is fine. |
The two main difficulties seem to be:
So I suppose 2 is only a problem because of RHL. But 1 would be a problem regardless. |
Regular webpack hot reload just reloads the entire page, why would 1 be still a problem? |
I mean if I’ve implemented |
I wonder why not to change styles in dev tools if instant feedback with current state is required. I guess its just all about habbits and preffered ways of editing. |
Yes I do use dev tools like that. But if I’ve changed a few different rules in the dev tools, switching back and forth between the browser and the editor to copy-paste things isn't possible because the editor’s auto-save causes the browser to refresh and lose my changes. With two screens, changing things directly in the editor on one screen and seeing the changes in the browser on the other screen means I don't have that copy-paste step between the dev tools and the editor. |
I was wrong about 1 being a problem with vanilla HMR - because if you re-render the entire React component tree, the proper component lifecycle occurs and JSS does clean up. Wow! So without const render = App => <ReduxProvider store={store}>
<JssProvider>
<App />
</JssProvider>
</ReduxProvider>
ReactDOM.hydrate(render(App), rootEl, () => {
...
})
if (module.hot) {
module.hot.accept('./App', function () {
const App = require('./App').default
ReactDOM.render(render(App), rootEl)
})
} And it works. It works with or without And I don’t need this package at all. |
I thought webpack hot reload just reloads entire page or are you doing something else right now? |
By default yes, the client in That’s all I ever needed - but it didn’t work for me when I first tried because I forgot to delete this from my webpack configuration: {
...
loader: require.resolve('babel-loader'),
options: {
plugins: ['react-hot-loader/babel'],
},
} That's enough to stop it working, because it generates proxies for my components so React does an update instead of unmounting and remounting. Ugh. Moving forward, this package would still be useful for users of
Does that sound reasonable @kof? |
Also @HenriBeck I’ve fixed the things you originally mentioned at the beginning of this issue, are they resolved to your satisfaction? |
Yes, looks good to me👍 |
@felthy this plan sounds reasonable! Lest do this! |
I have a few questions about the code.
Do we need this check, because the user should only add the plugin in the dev config anyway? This should remove the need for the ternary.
Is using the name here a good idea? Because when two components have the same name, we got a problem.
Also, I'm not a fan of the inline function in the ternary.
The text was updated successfully, but these errors were encountered: