Using Context to Build a Light/Dark Theme

Поділитися
Вставка
  • Опубліковано 12 лис 2024

КОМЕНТАРІ • 15

  • @capfarps
    @capfarps 2 роки тому

    THANK YOU SO MUCH, Context Api Its so simple, now I get it!
    thank you again

  • @myapptheme
    @myapptheme 3 роки тому +1

    Awesome tutorial. Very easy to understand and apply. Hats off to you dear mate.

  • @murilovs3827
    @murilovs3827 3 роки тому +1

    Thanks, it was pretty much what I was looking for.

  • @josephorji8331
    @josephorji8331 3 роки тому +1

    HELLO is there we can fix the white flickering light when navigating screens in dark mode?

  • @Tyrone-Ward
    @Tyrone-Ward 2 роки тому +2

    This is great! Other tuts use Redux which I think is overkill for switching themes.

  • @robertpatt-corner4418
    @robertpatt-corner4418 3 роки тому +1

    Attractive clear demo, helpful for the navigation and status bar details.
    But the tough problem remains unsolved, which is persisting the selected theme so that when a person selects dark the app *stays* dark across reboots and app stops; likewise light stays light. Not having persistence limits the utility of a theme change ... nobody wants to lose the theme across reboots, etc. especially when theme does more than just dark and light, e.g. a full palette.
    It's tough to solve persistence because you'd want to persist the theme on change (easy, just put it in AsyncStorage or something similar), then retrieve it on app start (tough because App is the parent component and any attempts to retrieve from storage take effect long after we need the value of the new theme. useEffect is the obvious approach, but it happens after App renders. And of course the App itself can't get a state as it does the wrapping with the context rather than is contained by the context.
    If you've solved that, or have ideas on it, I'd be most grateful and all ears.

    • @josephorji8331
      @josephorji8331 3 роки тому

      I THINK ONE OF THE WAYS TO SOLVE THIS IS BY LEVERAGING AsyncStorage

    • @matkomilic201
      @matkomilic201 3 роки тому

      Async Storage.

  • @cryptoknight7256
    @cryptoknight7256 3 роки тому +1

    Excellent tutorial as usual. Quick question: can I setup the default header style in stack and change it as needed via setOptions within useEffect?

  • @elgizhasanzada
    @elgizhasanzada 2 роки тому +1

    Thankssss so muchhhh

  • @mrmaurice8951
    @mrmaurice8951 2 роки тому +1

    Very usefull tutorial. I need dark theme to be stored on phone, so when a user closes the app it will remember whether the darktheme was on or off. And then on start displays the preferred theme. Now it is reset to default light theme. Any suggestion? I've looked into async storage in useeffect on load, but not working.

    • @ReactNativeSchool
      @ReactNativeSchool  2 роки тому

      We cover this concept in our "Build Offline Capable React Native Apps" course - www.reactnativeschool.com/building-offline-react-native-apps

  • @shine_at_dusk
    @shine_at_dusk 4 роки тому +1

    This is so useful! Thanks for the effort

  • @josephorji8331
    @josephorji8331 3 роки тому +1

    this is really handy thank you