How to type react element arguments
I want to take a string like this
but when i call it like this it says
So i try to use an anonymous class kind of thing
But that's some mess.
The following works
But that is ugly as hell, how do i write that properly ??
4 Replies
react components only have one "parameter" which is props. this means you need to use object connotations. Const example = ({guid, something_else}: {guid: string, something_else: string}) => { }
or
Type PropsType= {guid: string, something_else: string} Const example = ({guid, something_else}: PropsType) => { }
Type PropsType= {guid: string, something_else: string} Const example = ({guid, something_else}: PropsType) => { }
so
?
const Example = ({guid} : {guid:string}) => { ... }
thats as annoying as the absence of named arguemnts