-
Notifications
You must be signed in to change notification settings - Fork 799
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
react-hot-loader not work #947
Comments
Please double check console output. It should contain something. |
We have a lof of examples, and almost all of them uses webpack. Pick any, and try to use them. |
@theKashey Thanks for you response , i will try it later😄 |
@theKashey Hi, when i remove the react hot load , the webpack HMR can work , but add the react hot load, those component use redux can't hot reload , i add config in redux store like this if (process.env.NODE_ENV === 'development') {
if (module.hot) {
module.hot.accept('../reducers/index.js', () => {
store.replaceReducer(require('../reducers/index.js').default)
})
}
} change the those use redux component , save code, it doesn't change , and console the log
|
🤷♂️ only one file was updated, is that something you not expected? |
@theKashey Sorry for that i didn't describe my question clearly. I expect use react-hot-reload and webpack HMR for my react project to get better development experience , I use webpack HMR , when i change those component that associated redux , the page refresh , so I add react-hot-reload. According to some article add react-hot-reload need config redux store , so i config store like this: import { createStore, applyMiddleware } from 'redux'
import reducers from '../reducers'
import middleware from '../middleware'
const initialState = {}
const configureStore = () => {
// applyMiddleware(thunk, middleware)
let enhancer = applyMiddleware(...middleware)
const store = createStore(reducers, initialState, enhancer)
if (process.env.NODE_ENV === 'development') {
if (module.hot) {
module.hot.accept('../reducers/index.js', () => {
// const nextReducer = combineReducers(require('../reducers'))
// store.replaceReducer(nextReducer)
store.replaceReducer(require('../reducers/index.js').default)
})
}
}
return store
}
export default configureStore But it's don't work . I change the component those use redux , the app not change. Do i need config the redux store when i use react-hot-reload ? how to config ? I don't find how to config in react-hot-reload docs😅 My project: https://github.com/MrZhang123/Web_Project_Build/tree/master/react-webpack |
@theKashey I use react hot loader v4.1.2 , I find in docs that v4 add hot to get hot load , just add hot(module)(App) in root component . I think it means if I do this , the whole app component will hot reload . In fact , it's not , it just let root component get hot load . Does that means hot(module)(App) just can let component that add this code get hot load ? I want to whole react component get hot load , how to do this ? |
Hey! No, you dont need to add anything related to redux and so on. It should "just work"™️ |
@theKashey Thanks you response . I find that if I use react router (v4), the hot loader not work , so maybe react router cause this problem. |
Sorry for a delay. Only now I got some time to have a look. https://github.com/gaearon/react-hot-loader#code-splitting As long your components are updated, not remounter lifeCycle of your asyncLoader will not be triggered.
Better stick to first 2 options. |
@theKashey you means if I want all component have hot reload , I need to add |
No, only for the ones you are dynamically |
@theKashey ok, I understand , thanks for your reply 😄 |
@MrZhang123 actually i had the same proplem that I need to add hot(module)(componentName) for all component if I want all component have hot reload. So i would like to know how you fix it? thanks |
First try to update RHL. We had an error related to updates. |
Sry, i make a mistake that send hot:true and --hot at the same time, when i remove one of them, it works fine. |
I have a strange behavior. when i first save changes webpack compilation is successful and I see console updates in my browser with related network calls for the updated files, but my view is not updated. |
@hannadrehman - yep, we had bugs like it. React-Hot-Loaded failed to trigger forceUpdate on components, and React just didn't re-render them. I was absolutely sure, that I've fixed this half year ago. So - which version are you using, and do you have some code to reproduce? |
I'm seeing the same thing as described above. Successful compile, successful network calls for the new chunk, happy looking console log entries... but component does not re-render. I'm using latest version of |
|
Getting the same problem as @ryami333, and debug outputs I'm guessing its related to #963. UPDATE: |
In our internal tests react-loadable works pretty well. Could you share some details about your case, even if you fixed it already? |
Sure- Using the same HMR config as in the webpack docs... with babel plugins Had this same experience--with
Only thing I would add is that css changes did re-render. Components did not. Switching to |
anyway - I'll be keen if you could share some example, as long in our all-async-component-loaders-i-found example react-loadable is the one who actually works. |
Yeah. In this case, I realized that the issue was with React-Redux and as I downgraded from v6.0.0 to v5.1.1, it started working. Source: #1049 (comment) |
Description
I use react-hot-loader and webpack for HMR, i use
hot
for App , but when i save the code , hot reload not work , how i change ?Environment
node: 8.9.0
react-hot-loader: 4.1.1
webpack :4.6.0
webpack-dev-server: 3.1.3
Code
webpack.config.js
App.js
store.js
main.js
The text was updated successfully, but these errors were encountered: