Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

React useState vs variable

function Foo() {
    const [a, setA] = useState(0);
    return <div onClick={() => setA(a + 1)}>{a}</div>;
}

function Foo() {
    let a = 0;
    return <div onClick={() => a + 1}>{a}</div>;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #React #useState #variable
ADD COMMENT
Topic
Name
5+9 =