TS React Syntax
fix the following errortsxconst [names, setNames] = useState([])setNames([...names, 'bob'])
Type 'string' is not assignable to type 'never'.ts(2322)
const [names, setNames] = useState<string[]\>
([])
setNames([...names, "bob"])
React.FC
const MyApp: React.FC<ChildProps> = ({ color }) ⇒ {
const Child: React.FC<ChildProps\> = ({ color }) => {
return <div\>{color}</div\>;
};
props literal
const Child = (props: MyInterface) => {}
Refactor the following interfaces
interface UserSearchProps {
users: {
name: string;
age: number;
}[];
}
interface UserSearchState {
name: string;
user:
| {
name: string;
age: number;
}
| undefined;
}
interface UserSearchProps {
users: User[];
}
interface UserSearchState {
name: string;
user: User | undefined;
}
interface User {
name: string;
age: number;
}