index.js
import React from 'react'
import { master, setMaster } from './variableTest'
export default Home () {
[signedIn, setSignedIn] = React.useState(false)
[master, setMaster] = React.useState([])
return (<>...</>)
}
variableTest.js
var master, setMaster
export default master
export { master, setMaster }
现在,signedIn
是[]
,但是master
和setMaster
仍未定义。
我在;
的末尾添加了[signedIn, setSignedIn] = React.useState(false)
:
index.js
import React from 'react'
import { master, setMaster } from './variableTest'
export default Home () {
[signedIn, setSignedIn] = React.useState(false);
[master, setMaster] = React.useState([])
return (<>...</>)
}
发生错误:master
未定义。
在构建master
时,我想给setMaster
和Home()
一个新值。