我正在试图弄清楚我做错了什么,这是方案
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;
import React from 'react';
const Name = () => (<div>Yoshie</div>);
export default Name;
当我注销“name”时,它会注销一个connect函数而不是我期望的jsx:
function Connect(props, context) {
_classCallCheck(this, Connect);
var _this = _possibleConstructorReturn(this, _Component.call(this, props, context));
_this.version = versio…
我想知道我做错了什么......谢谢你的帮助!
答案 0 :(得分:1)
编辑:尝试在花括号内导入名称
import {Name} from './name'
class SayGreeting extends Component {
componentDidMount() {
console.log(name);
}
render() {
return (
<div>
Good Morning to you, <Name/>
</div>
)
}
}