-
-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ListBox now based on Radix Dropdown
- Loading branch information
1 parent
3c8880f
commit aae004f
Showing
7 changed files
with
186 additions
and
176 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,8 @@ | ||
import React, { createContext, useContext } from 'react' | ||
import { createContext } from 'react' | ||
|
||
interface ContextProps { | ||
formContextOnChange: any | ||
} | ||
// Make sure the shape of the default value passed to | ||
// createContext matches the shape that the consumers expect! | ||
const SelectContext = createContext<ContextProps>({ | ||
formContextOnChange: null, | ||
export const SelectContext = createContext({ | ||
onChange: (e: any) => {}, | ||
selected: undefined, | ||
}) | ||
|
||
export const SelectContextProvider = (props: any) => { | ||
const { formContextOnChange } = props | ||
|
||
const value = { | ||
formContextOnChange: formContextOnChange, | ||
} | ||
return ( | ||
<SelectContext.Provider value={value} {...props}> | ||
{props.children} | ||
</SelectContext.Provider> | ||
) | ||
} | ||
|
||
// context helper to avoid using a consumer component | ||
export const useSelectContext = () => { | ||
const context = useContext(SelectContext) | ||
if (context === undefined) { | ||
throw new Error( | ||
`useFormContextOnChange must be used within a FormContextProvider.` | ||
) | ||
} | ||
return context | ||
} |
Oops, something went wrong.