This is my first time using ReactJS and I keep getting error
'userData' is not defined no-undef
even when I declare it. Here's my code:
class Register extends Component { constructor(props) { super(props); this.state = { userData: [], fullName: "", email: "", uname: "", pass: "" } } onRegis = () => { const { fullName, email, uname, pass } = this.state userData = [{fullName, email, uname, pass}] this.setState({ userData }) console.log("Datanya euy: ", userData) // console.log(email, " is ", fullName, "'s email addres with username ", uname, " and password ", pass); } }`
You forgot define variable userData
by var
, let
or const
const userData = [{fullName, email, uname, pass}];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.