-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from iway1/object-arrays-and-checkbox-names
fixes issue with object arrays and checkboxes
- Loading branch information
Showing
4 changed files
with
108 additions
and
61 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
packages/trpc-panel/src/react-app/components/form/ProcedureForm/ProcedureFormContext.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React, { useContext } from "react"; | ||
import { createContext, ReactNode } from "react"; | ||
|
||
type ContextType = { | ||
path: string; | ||
}; | ||
|
||
const Context = createContext<ContextType | null>(null); | ||
|
||
export function ProcedureFormContextProvider({ | ||
children, | ||
path, | ||
}: { | ||
children: ReactNode; | ||
path: string; | ||
}) { | ||
return <Context.Provider value={{ path }}>{children}</Context.Provider>; | ||
} | ||
|
||
export function useProcedureFormContext() { | ||
const ctx = useContext(Context); | ||
if (!ctx) | ||
throw new Error( | ||
"Procedure form context must be called within ProcedureFormContextProvider (this is a bug with trpc-panel, open an issue)." | ||
); | ||
return ctx; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters