-
Notifications
You must be signed in to change notification settings - Fork 194
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
Not working on multiple named exports #249
Comments
This is expected behaviour. When there are non-React related exports, we cannot safely stop the update at the module itself since we do not know if it is side effect free. We will then propagate the change up to the parent(s). If this happens near the root, chances are that it will propagate through root and thus trigger a bail out (i.e. full refresh for web). |
Also just for my understanding please describe what do you mean by not working. |
I mean when export multiple items on the root component editing makes the web page trigger a full refresh , just like you say, forgive my poor english. |
This is expected behaviour. Let's say you are doing this:
import { render } from 'react-dom';
import App, { AppConstant } from './App.jsx';
render(<App />, document.getElementById('root'));
function App() {
return <div />;
}
export const AppConstant = 'AppConstant';
export default App; The issue with us automatically stopping the update at Now we have reached the root of the module graph - we cannot further propagate the update upwards - so unfortunately we need to bail out of HMR and do a full forced update (i.e. full page refresh).
My suggestion to this issue would be to keep the component closest to root only export itself - so at least you would have a final safe-guard boundary near root even you have deep trees that cannot update themselves due to multiple exports. I think it is more of how to organise code - correct me if this is wrong, but Recoil also suggest more atomic pieces of state and not having them at the root component is probably a right thing to do? There is not absolute need to export some atom state at the root component, right? |
Is this project used by create-react-app? I've just spent a few hours debugging an issue that it was stopping updates if there are multiple exports, but there is no full reload or any kind of warning. |
Yes, if you are on CRA v4.
This might have been a bug, I'm open to a reproduction to illustrate the issue. Note that we've also fixed quite a few things in the upcoming |
I tried it just now, on a new clean project. it is pretty straightforward to reproduce:
The problem for me here is not the fact that it is not reloading, but rather that there is no errors/warnings anywhere, which make it quite puzzling and making me think that I broke smth in my project setup. I am not sure if this is the issue with this package or with it's integration into CRA. |
See facebook/create-react-app#11105 - this is an error upstream with CRA. |
when the root component export multiple items , react refresh not working
here is the example
https://codesandbox.io/s/dry-flower-jq66q
If delete x from export ,then it works
Maybe this problem is related to react-refresh/babel ?
The text was updated successfully, but these errors were encountered: