0

error

I have an app which works on iOS but the Android version just broke somehow over the weekend. I had a working app before the weekend, and today I opened the app and I had to check the android version as well and it's not working. I commented all the code from the App.tsx basically I have a simple Test there.

Do you guys have any idea how can I fix this issue?

Thanks

Alpar Bartok
  • 31
  • 1
  • 4

1 Answers1

0

The reason for this issue should be, calling the setState({}) function continuously. For example, consider the below code snippet from class component,

class MyComponent() {
    componentDidUpdate() {
        this.setState({ someStateVariable: someValue })
    } 
}

This is one of the places where the setState({}) will be called again and again.

If you are using functional component, check the useEffect(() => {}) function carefully and avoid state update inside useEffect(()=> {}), without any conditions. Also avoid any state update outside of any functions.

For example,

const MyFunction(props) => {
    useEffect(()=> {
        setSomeStateVariable(someValue);
    });
}

This is the open useEffect without any parameter which will be called every change in the component, So we cannot use state update here without wrapping up with any conditions.

Also, check for any child component that updates its local state or parent state variable continuously.

Try to avoid using multiple useEffect(()=> {}), in a functional component.

Dhevendhiran M
  • 994
  • 2
  • 12
  • 29
  • Hi, thanks for your response but the issue isn't in the react-native code because I commented the whole think and I still got the error and also the iOS version of the app works perfectly. – Alpar Bartok Apr 20 '22 at 06:44
  • Also I managed somehow to make it work in debug mode but when I stop the debugging then I get the same error – Alpar Bartok Apr 20 '22 at 07:09
  • Can you please share some code snippets to understand the scenario even better? – Dhevendhiran M Apr 20 '22 at 09:35
  • Unfortunately I can't. But the Android folder was recreated following this post: https://stackoverflow.com/questions/43214862/how-to-rebuild-the-entire-android-folder App.tsx commented making sure that the issue isn't in the react-native code. On iOS everything works perfectly. My first guess was that I had a double linking or something like that at the dependencies but that's not the problem because I relinked everything automatically. – Alpar Bartok Apr 20 '22 at 14:17
  • I'll ask if I can share my code somehow, but what part of the code should I share, because I can't shared the whole project for sure – Alpar Bartok Apr 20 '22 at 14:18