mapStateToProps и переменная не определены React-Redux - PullRequest
0 голосов
/ 03 июня 2018

Я получаю эту ошибку:

. / Src / components / Playing.jsx Строка 15: «aaa» не определено no-undef

в моемPlaying.jsx:

import React, { Component } from 'react'

console.log(aaa);

Из моего токена.jsx

import { connect } from 'react-redux'
imports { Playing } from '../components/Playing'

const mapStateToProps = state => ({
  aaa: "asdf"
})

export default connect(mapStateToProps)(Playing)

1 Ответ

0 голосов
/ 03 июня 2018

Вы не сможете просто console.log() где-либо в файле;это должно быть в некоторой функции компонента Playing;и он также будет доступен только через props, например,

class Playing extends React.Component {
  componentDidMount() {
    console.log(this.props.aaa);
  }

  render() {
    return <span>Playing</span>;
  }
}
...