Open cjmling opened 2 years ago
Export type typescript example multiple string option
chandu.js
export type FilterBy = | 'total_value_locked' | 'apy' | 'liquidity' | 'type' | undefined interface filterContext { filterBy: FilterBy } const context: filterContext = { filterBy: undefined, } export const FilterContext = React.createContext(context)
bandu.js
import { FilterBy, FilterContext } from './filter-advance-context' const [filterBy, setFilterBy] = useState<FilterBy>(filterState.filterBy)
So basically we can declare using type and export it.
type
Then in other file we can import and use it as type
type string multiple option string
You may also import the object and use as typeof in this example it can be useState<typeof filterState.filterBy>(filterState.filterBy)
typeof
useState<typeof filterState.filterBy>(filterState.filterBy)
Export type typescript example multiple string option
chandu.js
bandu.js
So basically we can declare using
type
and export it.Then in other file we can import and use it as type
type string multiple option string