Home  >  Q&A  >  body text

Change app theme based on user selection in React Native via context API

In my app, the user selects a theme, I use context API and Asyncstorage to store the background color of the app, when the user selects a new color, it should affect the app through the context API.

However, when the app is removed from the background activity and restarted, it should not show the previously selected color, but the default color. Please help...

P粉351138462P粉351138462425 days ago594

reply all(1)I'll reply

  • P粉550257856

    P粉5502578562023-09-13 12:13:03

    Every time you open the application, check if there is any data you have retained in the Asyncstorage provided by the theme. You can update the Context API.

    reply
    0
  • Cancelreply