mirror of
https://github.com/Steffo99/festa.git
synced 2024-12-22 22:54:22 +00:00
Create a provider for the EditingContext
This commit is contained in:
parent
cef886a4ef
commit
9732f938b5
1 changed files with 14 additions and 0 deletions
14
components/generic/editable/provider.tsx
Normal file
14
components/generic/editable/provider.tsx
Normal file
|
@ -0,0 +1,14 @@
|
|||
import { ReactNode, useState } from "react"
|
||||
import { EditingContext, EditingMode } from "./base"
|
||||
|
||||
|
||||
/**
|
||||
* Component which stores the current editing mode (by default {@link EditingMode.VIEW}) using {@link useState} and provides it to its children through an {@link EditingContext}.
|
||||
*/
|
||||
export const EditingModeProvider = ({ children }: { children: ReactNode }) => {
|
||||
return (
|
||||
<EditingContext.Provider value={useState<EditingMode>(EditingMode.VIEW)}>
|
||||
{children}
|
||||
</EditingContext.Provider>
|
||||
)
|
||||
}
|
Loading…
Reference in a new issue