meteormeteor-react

Meteor React Form


I'm trying to render a form with data stored in the database. If I remove the form and wrap the PositionSingle input fields in a div the data renders correctly however I'm unable to make any changes. When I wrap the inputs in a form the component doesn't render.

I'm new to react with meteor so any assitance is appreciated.

Path: PositionSingle.jsx

render() {
    return (    
        <form className="new-position" onSubmit={this.addPosition.bind(this)}>
            <input 
                type="text" 
                ref="title"
                placeholder="Position title" 
                defaultValue={this.props.position.title} />


            <input 
                type="text" 
                ref="company"
                placeholder="Company"
                defaultValue={this.props.position.company} />       

            <button type="submit">Submit</button>
        </form>
    )
}

Path: PositionWrapper.jsx

render() {

    return (
        <div>
            {this.positions().map( (position)=>{
                return  <PositionSingle key={position._id} position={position} />
            })}             
        </div>
    )
}

Solution

  • This is a very old question, so I don't know if you still have the same project, even, but I like to make sure there are no loose ends if I can. That error looks like what @ThaiTran said, that you don't have addPosition defined in PositionSingle. After you add that, that error should go away. Did that work?