Skip to content
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

ThemeProvider causing Maximum update depth exceeded #3843

Open
1 task done
Geneonosis opened this issue Oct 5, 2023 · 2 comments · May be fixed by #3848
Open
1 task done

ThemeProvider causing Maximum update depth exceeded #3843

Geneonosis opened this issue Oct 5, 2023 · 2 comments · May be fixed by #3848

Comments

@Geneonosis
Copy link

Geneonosis commented Oct 5, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Explain what you did

switch from one branch that had older react-native-elements packages to new branch that has newer react-native-elements packages. did not have this issue when first updated branch months ago.

tried upgrading to newest rneui packages.

Expected behavior

Expected Behavior:

  • able to use ThemeProvider within SafeAreaProvider and NetworkProvider without infinite Maximum update depth exceeded errors.

What happens instead:

  • infinite maximum update depth exceeded.

Describe the bug

The following error is:

ERROR  Warning: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render.
   in ThemeProvider (created by [ommitted])
   in RNCSafeAreaProvider (created by SafeAreaProvider)
   in SafeAreaProvider (created by [ommitted])
   in [ommitted] (created by App)
   in PersistGate (created by App)
   in Provider (created by App)
   in App (created by withDevTools(App))
   in withDevTools(App)
   in RCTView (created by View)
   in View (created by AppContainer)
   in RCTView (created by View)
   in View (created by AppContainer)
   in AppContainer
   in main(RootComponent)

When I remove <ThemeProvider> from my project I do not get this error.

Steps To Reproduce

1. Insert <ThemeProvider> around <NavigationContainer> <OverflowMenuProvider> <DrawerNavigator />
2. Run `npx expo run:ios`
3. See error

Screenshots

No response

Your Environment

`npx @rneui/envinfo`
  ```
    React Native Elements Env Info

Global Dependencies:

No related dependency found

Local Dependencies:

  • @rneui/base : ^4.0.0-rc.7
  • @rneui/themed : ^4.0.0-rc.8
  • expo : ^48.0.9
  • react : 18.2.0
  • react-native : 0.71.4
  • @types/react : ^18.0.24
  • @types/react-native : ~0.70.6
    
    
@Geneonosis
Copy link
Author

I was able to resolve this issue by defining my own custom theme and passing it into the theme property of the ThemeProvider. however I still think something is broken with the package because the documentation states

If you do not specify theme in ThemeProvider, it would use defaultTheme

but that seems to not be working as without adding my own theme it bugs out.

@jeferson-sb jeferson-sb linked a pull request Oct 14, 2023 that will close this issue
14 tasks
@darkbasic
Copy link
Contributor

I've tried the PR but it didn't work.
The easiest workaround is the following:

const theme = createTheme({});
<ThemeProvider theme={theme}>

const theme = {} despite being allowed by the typings breaks the application even more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants