我只是想从容器中的对象文件传递给我的组件,并使用它。 容器的代码是这样的:
import { Meteor } from 'meteor/meteor';
import { withTracker } from 'meteor/react-meteor-data';
import { Projects } from '/imports/api/projects.js';
import ProjectFormUpdate from './ProjectFormUpdate.jsx';
export default ProjectFormUpdateContainer = withTracker(({ key1 }) => {
Tracker.autorun(() => {
const sub = Meteor.subscribe('projects');
if (sub.ready()){
const oneProject = Projects.findOne(key1);
console.log(oneProject.nombre);
}})
return {
oneProject,
};
})(ProjectFormUpdate);
我用它在我在这条路上表象组件:
render() {
const { oneProject, isLoading } = this.props;
if (!isLoading)
return (
<div className="col-xs-11">
<div className="box box-solid">
<form className="form" onSubmit={this.handleSubmit.bind(this)} >
<div className="box-body">
<div className="row">
<div className="col-xs-2">
<input
className = "form-control input-sm"
type="text"
ref="codigoInput"
placeholder="Código del Proyecto"
//THE PROBLEM HERE!!!!!
value = {this.props.oneProject.nombre}
onChange = {this.handleUpdate.bind(this)}
/>
</div>
...
但是,我得到这个错误: 类型错误:无法读取属性“农布雷”的不确定问题是行:
//THE PROBLEM HERE!!!!!
value = {this.props.oneProject.nombre}