在使用的react版本如下:
已写的部分代码(hook):
const [tempSlides, setTempSlides] = useState([])
const [community,setCommunity] = useState({
name: '',
id: ''
})
const [price,setPrice] = useState('')
const [size,setSize] = useState('')
已写的部分代码(state):
state = {
tempSlides: [],
community: {
name: '',
id: ''
},
price: '',
size: '',
}
请问以上四个hook可以像state那样写在一起吗?正确代码是什么?请展示代码举例说明,谢谢