use state reactjs
import {useState} from 'react'
const [count, setCount] = useState(0);
console.log(count) // returns 0
setCount(1)
console.log(count) // returns 1
use state reactjs
import {useState} from 'react'
const [count, setCount] = useState(0);
console.log(count) // returns 0
setCount(1)
console.log(count) // returns 1
use state in className
Standard fair:
const [toggleClass, setToggleClass] = useState(false)
return <div className={toggleClass ? 'some-class' : ''} />
Using template literals:
const [toggleClass, setToggleClass] = useState(false)
return <div className={`some-class ${toggleClass ? 'some-class' :''}`} />
use state
var fruitStateVariable = useState('banana'); // Returns a pair
var fruit = fruitStateVariable[0]; // First item in a pair
var setFruit = fruitStateVariable[1]; // Second item in a pair
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us