我试过2小时来渲染1个对象.
我的对象是:
const ObjectTest = {
1: {
id : 1,
name:'ABC'
},
3: {
id: 3,
name:'DEF'
}
}
Run Code Online (Sandbox Code Playgroud)
我想渲染:
id is 1 ; name is ABC
id is 3 ; name is DEF
Run Code Online (Sandbox Code Playgroud)
我想在一个函数中创建这个对象,并在render函数中调用.
谁能帮我?感谢所有提前:)
大家好我还是新手做出反应,我不知道,如何使用全局变量.我想让"this.props.topic.text"成为一个全局变量,以便在我项目的其他应用程序中使用它.我怎样才能做到这一点 ?
export default class Topic extends Component {
deleteThisTopic() {
Topics.remove(this.props.topic._id);
}
test() {
}
render() {
return (
<Router>
<div>
<ul>
<Link to="/sub"><li onClick={this.test.bind(this)}>{this.props.topic.text} ARN: {this.props.topic.arn}</li></Link>
<Link to="/log"><button onClick={this.test.bind(this)}>S'inscrire</button></Link>
<Link to="/"><button >Cacher</button></Link>
<button onClick={this.deleteThisTopic.bind(this)}>Suprimer</button>
</ul>
<hr/>
<Route exact path="/log" component={AppInscription}/>
<Route exact path="/sub" component={AppSub}/>
</div>
</Router>
);
}
}
Topic.propTypes = {
topic: PropTypes.object.isRequired,
};Run Code Online (Sandbox Code Playgroud)
我是一个新的单元测试Redux-thunk使用Jest的Action .
以下是代码:
export const functionA = (a,b) => (dispatch) =>{
dispatch ({type: CONSTANT_A, payload: a});
dispatch ({type: CONSTANT_B, payload: b});
}
Run Code Online (Sandbox Code Playgroud)
如何测试功能使用Unit-Test Jest?任何人都可以帮助我^^.预先感谢 :)