加载模块内redux连接



我正在努力找出我做错了什么,这是场景

Greeting.js

import React, { Component } from 'react';
import { connect } from 'react-redux';
import name from './name';
class SayGreeting extends Component {
  componentDidMount() {
    console.log(name);
  }
  render() {
    return (
      <div>
        Good Morning to you, {name}
      </div>
    )
  }
}
const mapStateToProps = ...
const mapDispatchToProps = ...
const Greeter = connect(
  mapStateToProps,
  mapDispatchToProps
)(SayGreeting)
export default Greeter;

name.js

import React from 'react';
const Name = () => (<div>Yoshie</div>);
export default Name;

当我注销"name"时,它注销了一个连接函数,而不是我期望的jsx:

function Connect(props, context) {
    _classCallCheck(this, Connect);
    var _this = _possibleConstructorReturn(this, _Component.call(this, props, context));
    _this.version = versio…

我想知道我是否做错了什么…谢谢你的帮助!

你试过吗,

编辑:try import大括号内的名字

import {Name} from './name'
class SayGreeting extends Component {
componentDidMount() {
  console.log(name);
}
render() {
  return (
    <div>
      Good Morning to you, <Name/>
    </div>
  )
 }
}

相关内容

  • 没有找到相关文章

最新更新