Wednesday, 11 October 2023

Multiple UpSell

React Hook Form

React Hook Form Tutorial

//sample
const [books, dispatch] = useReducer(bookReducer, [])

useReducer Hook

The idea behind it is the same as reduc. Here is useReducer doc

React Context

Here is react context toturial

  • Provider needs to wrap a children when return a provider. Here children has a special meaning of children components
  • in App.js, components will be wrapped by context provider
  • In the component itself, it can access context in three ways
    • contextType
    • consumer
    • const {isLight, light} = useContext(ThemeContext)

In Context file, we need to export both context and context provider

  • export const AuthContext = createContext()
  • export default AuthConextProvider (This is a component with AuthContext.Provider)

No comments:

Post a Comment