score:9
Accepted answer
Starting with 3.2 the behaviour of the spread operator for generics has changed. Apparently the type of props
gets erased as a negative side effect, but you can work around that by casting it back to P
using {...props as P}
when spreading back into the wrapped component.
Source: stackoverflow.com
Related Query
- React & TypeScript HOCs - why I get Type '{}' is not assignable to Type P?
- Why I get typescript error: Argument of type 'string | FilterData[] | number[] | Moment[]' is not assignable to parameter of type 'string'?
- React Typescript - Argument of type is not assignable to parameter of type
- React Router 6 and Typescript - index attribute Type 'true' is not assignable to type 'false | undefined'.?
- React with TypeScript - Type {...} is not assignable to type 'Readonly<S>'
- Type 'void' is not assignable to type '((event: ChangeEvent<HTMLInputElement>) => void) React TypeScript
- React Typescript error in TextArea : Type 'string' is not assignable to type number
- Typescript error: Type 'string' is not assignable to type '"allName" | `allName.${number}.nestedArray`' in react hook form
- Creating reusable Button Component with React and Typescript with not assignable type error
- React js Typescript Argument of type 'string' is not assignable to parameter of type 'SetStateAction<number>'
- TypeScript React Js, Type 'void' is not assignable to type '((event: MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined'
- TypeScript w/ React - Argument of type 'string' is not assignable to parameter of type 'keyof T'
- got Type 'void' is not assignable to type '() => void' in react typescript
- React Redux connect is not assignable to type '() => void' with typescript
- React Typescript error Type '{ id: number; title: string; function(): void; }' is not assignable to type 'null'
- React with Typescript | Functional component | Type 'boolean' is not assignable to type 'ReactElement<any, any>'
- Typescript complaining about React useState setter `Argument of type 'Dispatch<SetStateAction<never[]>>' is not assignable to parameter of
- getting error :Type '[null, Dispatch<SetStateAction<null>>]' is not assignable to type in typescript react
- Why is TypeScript telling me "Type '{ walletAddress: string; }' is not assignable to type 'string'.ts(2322)" even though I am passing a string?
- Property 'props' does not exist on type '{}' (trying to get access to props of children) - React Typescript
- react typescript error 'Type '{ ... }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<...>
- React typescript - Type 'boolean' is not assignable to type
- Typescript React - Type 'string' is not assignable to type 'Appearance'
- passing file as prop in react typescript (Type 'true' is not assignable to type 'ChangeEventHandler<HTMLInputElement>)
- Error in typescript using react framer Type '() => void' is not assignable to type 'undefined'
- Type 'string' is not assignable to type 'never' and Type 'unknown' is not assignable to type 'never' error in react typescript
- Typescript React type argument of type not assignable to parameter of type
- TypeScript React event handler error; type is not assignable to type (union)
- Typescript - React Error TS2322: Type 'AppState | undefined' is not assignable to type 'ICards | undefined'
- Typescript error on React Component: Argument of type 'Element' is not assignable to parameter of type
More Query from same tag
- React Js, adding new object to an array
- How to handle invalid routes in Nodejs?
- Styled-Components Text or Paragraphs
- removing an index from an array of objects in react.js always removes the last index
- Passing props to temperate literal in map
- How to deselect option on selecting option of another select in react
- React-Redux app: How to make that in this field on my page only some part of data displayed?
- Redux in NextJS
- How to avoid jsx styling error in react native?
- React-table onFetchData getting triggered twice
- React - passing refs as a prop
- Load same configuration after component is re-rendered or the page is refreshed in react
- ReactJS How to Show Answers from list when click on questions
- regexp to match basic arithmetic with letters and put them in groups
- React-native using a state variable while getting data from fetch
- Type 'number' is not assignable to type 'string | undefined'
- Filtering Data to load a particular response on click
- useHistory react-router-dom invalid hook call
- ReactJS: Prop referencing a state var. is not updated after parent's state change
- most concise way to pass props to a react component?
- Render item from an array after a fixed interval in React
- Equivalent of FlatList from React Native in React
- Simple react setState
- React Native - How to Build an Image Grid like FaceBook
- useNavigate doesn't load page when navigating between siblings component
- Issue wtih exit property - framer motion
- React, observer stateless component with typescript
- React Prop Types vs Typescript
- Can you add a key to a React JSX Element after it's instantiated?
- React refreshes component after function call