Comments (5)
Webpack hot module updates follow the import chain. As long as a module “ends up” being imported from components only, hot updates will work. If a specific module import chain ends in something like index.js
which is not a component, hot updates will fail because react-transform-hmr
has no idea how to handle updates to something other than components.
That said you can write manual code to handle hot updates of modules that don’t end up consumed by components. For example, this is how we hot replace reducers in Redux.
from react-transform-boilerplate.
Is there a way to plugin to the React HMR features to extend it and make it aware of my code?
I'm working on code that reads config in JSON and creates React elements on the fly, so the HMR proxying doesn't work. I basically have a top-level function that returns a React Router element, which delegates to functions that create React component classes through currying. My goal is changes the JSON configuration file triggering hot updates to the React app produced by that json->react transform function.
If this use case isn't a good fit for React HMR, that's a totally reasonable answer -- I've considered implementing json config->React app as a compile-time transform (probably as a webpack loader for the JSON config file).
from react-transform-boilerplate.
Do you care about preserving component local state (this.state
) on hot reloads? If not, just don’t use proxying and use raw HMR API to replace the whole component subtree with a new version like here.
from react-transform-boilerplate.
Oh that's awesome and exactly what I need, thanks!
On Mar 5, 2016 12:42 PM, "Dan Abramov" [email protected] wrote:
Do you care about preserving component local state (this.state) on hot
reloads? If not, just don’t use proxying and use raw HMR API to replace the
whole component subtree with a new version like here
reduxjs/redux#1455.—
Reply to this email directly or view it on GitHub
#120 (comment)
.
from react-transform-boilerplate.
Thank you for your answer.
from react-transform-boilerplate.
Related Issues (20)
- Do we need babel-polyfill in production HOT 1
- React transform or hmre? HOT 1
- Debug in devtools HOT 1
- Can you give an example of how to use with webpackDevServer? HOT 3
- Feature request: Built in redux-devtools HOT 1
- console shows error: Uncaught Invariant Violation HOT 5
- github archive doesn't contain .babelrc HOT 1
- How to view app in mobile device? HOT 2
- There are some problem and suggest. HOT 1
- Weird behaviour when adding text HOT 3
- Problems with NoErrorsPlugin HOT 2
- Doesn't work with react Component class wrapper HOT 3
- Error when using Webpack 2 and es2015-webpack preset HOT 4
- Doesn't work with React-Router :( HOT 5
- Failed at start script 'NODE_PATH='source' node devServer.js' HOT 1
- How to load css
- React.PureComponent doesn't work with HMR HOT 2
- Stateless functional component not hot reloading HOT 1
- hotReload is not work
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-transform-boilerplate.