test with firebase
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Chantier, Chef, exempleChantier } from '@/class/class';
|
||||
import { createContext, ReactNode, useContext, useMemo, useState } from 'react';
|
||||
import { Chantier } from "@/class/class";
|
||||
import { createContext, ReactNode, useContext, useMemo, useState } from "react";
|
||||
|
||||
type ChantierContextType = {
|
||||
chantier: Chantier | null;
|
||||
@@ -15,10 +15,7 @@ type ChantierProviderProps = {
|
||||
export const ChantierProvider = ({ children }: ChantierProviderProps) => {
|
||||
const [chantier, setChantier] = useState<Chantier | null>(null);
|
||||
|
||||
const value = useMemo(
|
||||
() => ({ chantier, setChantier }),
|
||||
[chantier]
|
||||
);
|
||||
const value = useMemo(() => ({ chantier, setChantier }), [chantier]);
|
||||
|
||||
return (
|
||||
<ChantierContext.Provider value={value}>
|
||||
@@ -30,7 +27,7 @@ export const ChantierProvider = ({ children }: ChantierProviderProps) => {
|
||||
export const useChantier = () => {
|
||||
const context = useContext(ChantierContext);
|
||||
if (!context) {
|
||||
throw new Error('useChantier doit être utilisé dans <ChantierProvider>');
|
||||
throw new Error("useChantier doit être utilisé dans <ChantierProvider>");
|
||||
}
|
||||
return context;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user