The first step is to create the context, for example, UsernameContext.js:

import { createContext } from ‘react’; const UsernameContext = createContext(“”); export default UsernameContext;

The second step is (1) initiate the context values and (2) use the context provider. Note that this should be done at the parent level.

import { useState, useContext } from ‘react’;
import UsernameContext from ‘./UsernameContext’ const [username, …