How can i retrieve only one entry? ,I have this this
import React, { Component } from 'react';
import { createContainer } from 'meteor/react-meteor-data';
//api entries
import { muscleGroups } from '../../api/muscleGroups.js';
export default class editMuscleGroup extends Component {
getMuslceGroup(){
return (
<span>{this.props.muscleGroup.type}</span>
)
}
render (){
return <div>--{this.getMuslceGroup()}--</div>;
}
}
editMuscleGroup.propTypes = {
muscleGroups: React.PropTypes.object
};
export default createContainer((params) => {
return {
muscleGroup:muscleGroups.findOne({type:params.params.type})
};
}, editMuscleGroup);
import { Mongo } from 'meteor/mongo';
export const muscleGroups = new Mongo.Collection('muscleGroups');
but is not working for me , I get undefined on this.props.muscleGroup.type
I use latest version of Meteor , with react
params.params.type is from the Link component
What I want is to use an link to transfer the user to an editing page of a single muscleGroup
When I click from the list of muscleGroups I get the expected result but if I refresh I get the TypeError: Cannot read property ‘type’ of undefined"
what I am missing ?
tanks in advance