我收到此错误:
./ SRC /组件/ Playing.jsx 第15行:' aaa'未定义no-undef
在我的Playing.jsx中:
import React, { Component } from 'react'
console.log(aaa);
来自我的Token.jsx
import { connect } from 'react-redux'
imports { Playing } from '../components/Playing'
const mapStateToProps = state => ({
aaa: "asdf"
})
export default connect(mapStateToProps)(Playing)
答案 0 :(得分:2)
您无法在文件中的任何位置console.log()
;它需要在Playing
组件的某个函数内;它也只能通过props
提供,例如
class Playing extends React.Component {
componentDidMount() {
console.log(this.props.aaa);
}
render() {
return <span>Playing</span>;
}
}