score:0
Accepted answer
- extend
fruitlist
type (eg:otherlist
)
type fruitcode = 'apple' | 'banana'
interface fruitlist {
name: fruitcode
}
// add this type
interface otherlist extends fruitlist {
name: string
}
- use
otherlist
insetstate
const [arr, setarr] = usestate<otherlist[]>([])
Source: stackoverflow.com
Related Query
- extend typescript type in react setState
- React with typescript - type safety with setState
- How to extend a ref type for forwardRef in react and typescript to allow multiple refs
- Typescript react - Could not find a declaration file for module ''react-materialize'. 'path/to/module-name.js' implicitly has an any type
- How do I restrict the type of React Children in TypeScript, using the newly added support in TypeScript 2.3?
- What is the TypeScript return type of a React stateless component?
- allow typescript compiler to call setState on only one react state property
- React with Typescript - Type { } is missing the following properties from type
- React component type in TypeScript
- React Typescript - Argument of type is not assignable to parameter of type
- Typescript React <Select> onChange handler type error
- React event type in Typescript
- How do I create a TypeScript type definition for a stateless React component?
- TypeScript conditional types: Extract component props type from react component
- How can I define TypeScript type for a setState function when React.Dispatch<React.SetStateAction<string>> not accepted?
- React + TypeScript only allow children of specific type
- Specify type for file upload event in react typescript
- How to extend a native's component's props TypeScript interface in a stateless, functional component in React Native?
- How to extend HTML attributes in React with Typescript
- how to type state and dispatch for useReducer - typescript and react
- what is the correct type for a React instance of a component in typescript
- How do you set the Typescript type for useRef hook in React Native?
- React Typescript how to setState
- Assigning type to a React SFC function declaration in TypeScript
- React Router 6 and Typescript - index attribute Type 'true' is not assignable to type 'false | undefined'.?
- Parameter 'e' implicitly has an 'any' type React TypeScript
- react hooks and typescript - Property '***' does not exist on type 'never'
- TS2339: Property 'focus' does not exist on type '{}'. with React typescript
- How do you correctly use React.lazy() in Typescript to import a react component with a generic type parameter?
- React with TypeScript - Type {...} is not assignable to type 'Readonly<S>'
More Query from same tag
- How could I use a module to pass in a react component?
- Nextjs How to map multiple routes to one page?
- How to use jest to mock out a private variable
- Access value of useState in theme
- How to pass objects and states between two components in React
- API Fetch with reactjs and show into graph
- In the following React code why the reference to the element is not returned?
- React - how to wait and fade out?
- How to find if one of the items have completed property with value false from an array of objects using javascript and react?
- i'm trying to make a axiosGET request to my react component, i get the object on the console.log. But when i try to render it i get a "is not defined"
- how to make a recursive function asynchronous
- missing some cases in createcontext
- How can I set the function to a state without the function being called?
- Generic type in reactjs
- Rails Backend And React Frontend Uncaught TypeError: Cannot read property 'url' of undefined
- Element type is invalid error using react-native and react navigation
- ReactJS - firebase how query a record with particular .key
- Having issues sending props from a api call into another react component
- get empty request while posting
- React JS - How to add value from state to specific element
- File upload to custom folder in react
- Passing data from one component to another component
- Custom data attribute not working with MUI 5 using textfield select prop
- Update Url without refreshing page
- Impossible to get the value of an Usestate in a function
- Conditional type based on value of other prop
- How can I stop auto spacing in VS code in a react file?
- How to set a value on rsuitejs selectpicker
- React Redux: Unable to Map array of Objects
- 'Symbol' is undefined in IE after using babel