Giter Club home page Giter Club logo

exercise-w10-state-management-context's Introduction

React State Management Theme Switcher with useContext Exercise

For this weeks practice you will Create a simple theme switcher where dark/light mode are managed using React's useContext.

Getting Started with the Project

Dependency Installation & Startup Development Server:

Once forked and cloned, navigate to the project's root directory and this project uses npm (Node Package Manager) to manage its dependencies.

The command below is a combination of installing dependencies, opening up the project on VS Code and it will run a development server on your terminal.

npm i && code . && npm run dev

Looking for some hints?

  1. Theme Management with useContext

    • The useContext hook in React allows you to access values from a context without prop-drilling. For this exercise, you're using it to manage a simple theme switcher (light/dark mode).
    • Define a context using createContext(). Remember to export both the context and a custom hook (e.g., useTheme) to make it easier to access the theme in your components. Follow the naming conventions when you create folders and files. Have a look at the boilerplate if you need guidance.
  2. Integrating Components

    • In your main App.jsx, import the theme toggler.
    • Ensure that the ThemeProvider wraps your entire application so that the theme context is accessible everywhere.
  3. Testing

    • Before pushing to GitHub, test your application and make sure it toggles the theme. Ensure everything works seamlessly.
  4. Committing and Pushing

    • Use git add . to stage your changes, followed by git commit -m "Your commit message here" to commit them.
    • Push your changes to the GitHub repository using git push origin main.

exercise-w10-state-management-context's People

Contributors

antonellamorittu avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.