App goes back to the initial screen when using fast refresh #455
Replies: 5 comments 13 replies
-
I usually see this happen when saving changes to a |
Beta Was this translation helpful? Give feedback.
-
i discovered that if you have const outside the react component (for me it was zod schema) it will make that specific screen/component re-render the whole application. Fast Refresh is only on react component si if you have variable or function exported outside and initialized outside the react component context, it will trigger a full re-render. Only way i found to avoid that was to make anything outside react a function that i can call and init in the component itself. |
Beta Was this translation helpful? Give feedback.
-
I had this problem too but I figured it out by my self as I didn't find anything related to it, It is a hard Routing Issue. Routing problems can arise from various sources, such as incorrect configuration or mismanagement of routes. Even a small oversight, like a misplaced '/' in your routes, can lead to unexpected behavior. To resolve these issues, it's crucial to follow best practices outlined in the documentation. This includes properly configuring your app's routing within layouts and ensuring that all routes are defined correctly. Identifying and fixing routing problems often requires some trial and error. Through practice and experimentation, you can pinpoint the root cause of the issue and implement the necessary fixes. If you're still facing difficulties or if you need further clarification on any aspect, feel free to reply to this message, and I'll be happy to assist you further. Happy coding! 😊 |
Beta Was this translation helpful? Give feedback.
-
Hi! I experienced the same issue with the app going back to initial screen (fast refresh) every time I saved a change. import React from 'react';
import { View, Text } from 'react-native';
const settings = () => {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Settings page</Text>
</View>
);
};
export default settings; When I change the screen name (see code below) with capital first letter everything was working again 🥳 import React from 'react';
import { View, Text } from 'react-native';
const Settings = () => {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Settings page</Text>
</View>
);
};
export default Settings; |
Beta Was this translation helpful? Give feedback.
-
Hi For my part the problem is that i was doing this : ❌ BAD PRACTICE ❌ import { View, Text } from 'react-native';
export default Settings = () => {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Settings page</Text>
</View>
);
}; ✅ GOOD PRACTICE ✅ import { View, Text } from 'react-native';
const Settings = () => {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Settings page</Text>
</View>
);
};
export default Settings; Now the modified screen remains in place without returning to the initial screen ✅ |
Beta Was this translation helpful? Give feedback.
-
Every time I make a change and fast refresh is fired I go back to the initial screen. Is there a way to keep the current screen when developing? It's super annoying to navigate to the screen I am developing on every code change. I remember that was possible using React Navigation.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions