Clone of Facebook using React and Material UIa
Facebook Clone
Tech Stack: React
Context API
Firebase 9
Material UI
Features: Real Time DB
Google Authentication
Mobile Responsive
Add Posts with images
Description
Login Screen
Google Authentication
Main Page
Mobile Responsive
Dependencies
-
npm install @mui/icons-material @mui/material @emotion/styled @emotion/react
-
npm i firebase
StateProvider.jsx
-
createContext()
creates a new context object, which can be used to pass data down the component tree without having to pass props manually at every level. -
export const StateContext = createContext();
creates a new context object called StateContext and exports it. This context object will be used to store the global state. -
export const StateProvider = ({ reducer, initialState, children }) => ...
creates a new component calledStateProvider
. This component takes three props:reducer
,initialState
, andchildren
. -
The
StateProvider
component renders aStateContext.Provider
component with avalue
prop set to the result of callinguseReducer
with thereducer
andinitialState
props.useReducer
is a hook that returns an array with two values: the current state and a dispatch function to update the state. By setting thevalue
prop to the result ofuseReducer
, theStateProvider
component provides the global state to any component that consumes theStateContext
. -
export const useStateValue = () => useContext(StateContext);
creates a custom hook calleduseStateValue
. This hook uses theuseContext
hook to consume theStateContext
and returns the current state and dispatch function. Any component that needs to access the global state can use theuseStateValue
hook to consume theStateContext
.
Deploy
-
npm install -g firebase-tools
-
firebase login
-
firebase init hosting
-
public directory – build/ dist (CRA/ Vite)
-
npm run build
-
firebase deploy –only hosting