Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react typescript set type

interface MyFooType {
    value: string;
}

const [foo, setFoo] = useState<MyFooType>(); // if not array

const [foo, setFoo] = useState<MyFooType[]>([]); // if it's an array
 
PREVIOUS NEXT
Tagged: #react #typescript #set #type
ADD COMMENT
Topic
Name
6+7 =