A simple responsive Sign In Page with Navbar.
Context provides a way to pass data through the component tree without having to pass props down manually at every level.
In a typical React application, data is passed top-down (parent to child) via props, but this can be cumbersome for certain types of props (e.g. locale preference, UI theme) that are required by many components within an application. Context provides a way to share values like these between components without having to explicitly pass a prop through every level of the tree.
For More, read this very good React-Context Documentation
Also, there is much of a debate lately in React community when you should use context vs Redux. Well, with the coming of Hooks, it's been easier than ever to use Contexts inside your React App.
In this App, you can see the use of Context API, for a cleaner and less pain-some code, rather than manually passing props at each level.
Also, in this very App, you can see the difference between using the API by using Class Components for Context API vs using Hooks for Context API and will appreciate how easy it is to use Hooks for this feature, as well as for variety of other use cases too
- @material-ui/core: library containing the core Components for Material UI
- @material-ui/icons: This package provides the Google Material icons packaged as a set of React components.
-
Open terminal,
cd
to your fav Projects folder and type:git clone https://github.com/shivamjjha/React-context-api-demo
-
Switch to the Project's directory:
cd React-context-api-demo
-
Install Dependencies:
npm i
-
Start the hot-reloading server:
npm start
-
This will serve this project at http://localhost:3000/ (by default).
-
To reflect changes in the project, edit the required files and save.
This project was bootstrapped with Create React App.
npm test
Launches the test runner in the interactive watch mode.
See the section about running tests for more information.
npm run build
Builds the app for production to the build
folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.
Your app is ready to be deployed!
See the section about deployment for more information.
npm run eject
Note: this is a one-way operation. Once you eject
, you can’t go back!
If you aren’t satisfied with the build tool and configuration choices, you can eject
at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject
will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
You don’t have to ever use eject
. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
You can learn more in the Create React App documentation.
To learn React, check out the React documentation.
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify