yasshi2525/RushHour

View on GitHub
client/src/common/admin.tsx

Summary

Maintainability
A
0 mins
Test Coverage
import React, { FC, createContext, useMemo, useEffect } from "react";

const AdminPageContext = createContext(false);
AdminPageContext.displayName = "AdminPageContext";

export const AdminPageProvider: FC<{ admin?: boolean }> = props => {
  useEffect(() => {
    console.info("after AdminPageProvider");
  }, []);
  return useMemo(
    () => (
      <AdminPageContext.Provider value={props.admin === true}>
        {props.children}
      </AdminPageContext.Provider>
    ),
    []
  );
};

export default AdminPageContext;