The ProductsContainer

In the following figure, we have a ProductsContainer as the top-level parent component connected to the data source:

The functionality of the ProductsContainer is to load all the products from the ProductsCollection and render a Product presentational component for each product item. As always, we pass the data down as props.

To access the data, we need to import both the collections from the shared directory.

We will read the data from ProductsCollection and, on a user action, we will insert, update, or delete an item in the CartCollection:

import React from 'react';import { createContainer } from 'meteor/react-meteor-data'; ...

Get Build Applications with Meteor now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.