Let's say there's a collection called Todos
and the autopublish
package is added. Here is the basic component.
import { createContainer } from 'meteor/react-meteor-data';
import React, { Component, PropTypes } from 'react';
import Todos from '/imports/collections/Todos';
export class List extends Component {
render() {
const { data } = this.props;
return (
<ul className="list">
{data.map(entry => <li {...entry} />)}
</ul>
)
}
}
List.propTypes = {
data: PropTypes.array.isRequired
};
At the bottom, you can add a container to feed the reactive data into the component. It would look like this.
export default createContainer(() => {
return {
data: Todos.find().fetch()
};
}, List);