Questions
The following questions will check what you have learned in this chapter:
- What type will the
name
prop have in the following component, which has no type annotation?export function Name({ name }) {
return <span>{name}</span>;
}
- What type will the
firstName
state have in the followinguseState
statement?const [firstName, setFirstName] = useState("");
- A
ContactDetails
component has the following type for its props:type Props = {
firstName?: string;
email: string;
};
export function ContactDetails({ firstName, email }: Props) {
...
}
The preceding component is referenced in another component’s JSX as follows:
<ContactDetails email="fred@somewhere.com" />
Will a type error be raised?
- A
status
state variable can hold the"Good"
and"Bad"
values and is initially"Good"
. It is defined in the following code:const [status, setStatus...