Comments (7)
This is probably better discussed in RHL repo.
Anyway, here’s my perspective.
RHL introduced a lot of mess into the ecosystem because people ran after shiny things without actively working on the underlying infrastructure. As a result we got 10,000 boilerplates with varying degrees of brokenness. Everybody wanted “hot reloading” but few knew how to configure it correctly, and many ended up with development code in production builds, spent days trying to get HMR to work, blamed Webpack and React, had broken dependency updates, etc.
It was partly my fault, and I wanted to fix it. For the past few months I’ve been working on Create React App which is my attempt to build a solid foundation for adding developer experience features without burdening app developers. Since the configuration is hidden, you can’t configure it incorrectly. Since dependencies are hidden, you don’t need to worry about updating them one by one and solving the resulting issues. Since it works on top of lower-level technologies, it can patch over their faults and deliver a better integrated experience.
I still care about hot reloading a lot. But I think I have been doing it in the wrong order all this time. I should have focused on stability first before the hype came in. I don’t think that continuing to work on React Hot Loader in its current form is the best use of my time right now, and I’m happy to hand over maintenance to other people (thanks @calesce for stepping up!) People still see hot reloading as something gimmicky, fragile, and flaky. It is not a good default yet. This is what I want to fix, but the way to fix it is by building trust in the tools. It doesn’t just need to work, it needs to work well in every case, or do full refresh when it can’t. There should never be a situation where you aren’t sure if it worked because this builds up the frustration.
Here is my current plan about adding hot reloading to React:
- Make Create React always refresh the page on change so people learn to trust it and stop pressing “refresh” themselves.
- Add syntax error overlay to Create React App so that people spend more time in the browser and aren’t afraid that making errors forces them to look at terminal or console.
- Add a “redbox” in Create React App on any JavaScript error in development. This helps ensure page never appears broken, and that people spend even less time in the DevTools console, and more time in the browser app section.
- Add the necessary hooks to React to avoid hacks like this, a top-level
<AppContainer>
, ormodule.hot.accept
code. The user shouldn’t change their code in any way for hot reloading to work. Incidentally we need the same hooks for React DevTools so it aligns with React team plans. - Enable a simple implementation of hot reloading that is guaranteed to work in 100% cases without any hacks like proxies and associated pitfalls. In practice this means that I’ll likely enable it only for stateless functional components defined in separate files. We recommend extracting markup-heavy code into separate components anyway so this encourages cleaner component structure.
At every point of time the goals are:
- It works 100% of the time.
- When it can’t hot reload, it refreshes 100% of the time.
- The page never ends up in a broken state due to hot reloading.
- Every error is reported clearly.
- People don‘t get confused “whether it worked or not”.
- Changes to React internals won’t suddenly break anything because we only use public APIs.
I am focusing on Create React App because I believe that hot reloading can only work truly well if it’s a part of an integrated experience we can fully control. Otherwise small incompatibility issues will keep it flaky. I also don’t necessarily want this to be branded as React Hot Loader. I want people to associate hot reloading with React itself, as an officially supported part of the default setup. We’ll see if we can make it work well enough to deserve this.
A project like React Hot Loader also has its place, as it attempts to solve many more use cases. But it has proven impossible for me to deliver the quality I want with it. I’m trying something different with the integrated approach now. I understand that not everybody may be onboard with my goals and methods, and that’s fine. I’d love to see people try different things as opposed to everyone relying on RHL, and I’d also love to see people keep improving RHL itself as it has slightly different goals.
I hope this clarifies it a little!
from react-hot-boilerplate.
Next step: facebook/create-react-app#783.
from react-hot-boilerplate.
So, we finally released the error box in Create React App which means we can start experimenting with hot reloading in some ways in the future.
from react-hot-boilerplate.
I've previously archived this repo but I'm unarchiving it now just to comment that we did it.
https://reactnative.dev/blog/2019/09/18/version-0.61
https://nextjs.org/blog/next-9-4
https://github.com/facebook/create-react-app/releases/tag/v4.0.0
It just took a few more years than planned.
from react-hot-boilerplate.
@gaearon is my hero
from react-hot-boilerplate.
@gaearon Thank you for a detailed and comprehensive response. Respect. Closed
from react-hot-boilerplate.
facebook/create-react-app#2304
from react-hot-boilerplate.
Related Issues (20)
- React native view swiper HOT 1
- Using boilerplate with react-hot-loader/webpack loader HOT 1
- [HMR] Update failed: Error: Manifest request to /static/[hash].hot-update.json timed out. HOT 4
- Does the next branch work? HOT 1
- Version 3 Release Date HOT 1
- No error display with next branch? HOT 1
- Express res.sendfile(bundle) just loads browser with plain JS source in the actual window
- whether has the plan to release a standard version to use webpack to 2.x HOT 1
- Double WDS client in the next branch
- Next branch: after hot reload, redux-connected component not re-rendered in response to redux state change HOT 2
- No solution for server-side rendering HOT 1
- Bundle is 190kb from 150kb when updated from webpack v3
- Hot loading and iframes
- Webpack plugin is not working is `three-shaking` is enabled
- The guide page based on is gone, return 404.
- Receive error upon clone
- Hot Reload only works after changing files multiple times, very annoying. HOT 3
- Hola
- not working if I made some changes in functions HOT 1
- not working well with webpack 4 and happypack HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-hot-boilerplate.