React tutorial errors (?)

In the Meteor React tutorial - https://www.meteor.com/tutorials/react/components - it says that I need to include these lines:

import React from ‘react’;
import { Meteor } from ‘meteor/meteor’;
import { render } from ‘react-dom’;

I have mananged to create an app (using Meteor 1.3) wihtout needing to include these lines, so is the tutorial incorrect?

Meteor’s default behavior is to automatically “import” every package that was available, but we don’t encourage people to use that behavior any more, because it can make apps more difficult to debug. So the answer to your question is: no, it’s not a mistake, it was intentional :slight_smile:

ok. Could you kindly point me ni the direction of the article/tutorial that talks about manually importing things (not just React, but generally) - at the moment I don’t know what I should/shouldn’t be importing and how that should be done - thanks in advance.

Check out this section of the Meteor Guide: http://guide.meteor.com/using-packages.html
Let us know if you find that it is not clear after reading it.

1 Like

Meteor 1.3 still provides global namespacing for Meteor packages for backwards compatibility for apps not using import.

Ok, so I need to start using the imports in my app. - do I just import all packages used in my ‘startup.js’ file (i.e. the js file that is first touched by Meteor), or do I use the imports at the top of each .js file that is likely to use it, i.e. every react component js file?

I noticed that the Meteor guide “Using createContainer” that it refers to creaitng a ListsShowPage container, but the actual code block doesn’t include ‘ListsShowPage’ anywhere - am I missing something?

The Guide pulls code samples out of the associated reference app, todos. Check out the todos app for complete code samples.

At the moment it’s incoherent without a reference to the code for ListsShowPage.

It’s difficult to fit all relevant code in the Guide (while maintaining readability), so it tries to only include the parts it needs to explain the current section or idea. This definitely works better in some sections than others. That being said, it looks like the createContainer section no longer lines up with the react branch of the todos app (e.g. refers to a ListsShow component that is now a ListPage component, the ListsShowPage container is now the ListContainer, etc.). I’ll submit a PR for this.

Please feel free to submit an issue or better yet a PR via https://github.com/meteor/guide if you think anything in the Guide is unclear and should be changed.

(EDIT: PR reference: https://github.com/meteor/guide/pull/346)

1 Like

Much appreciated - i’ll bare in mind the PR on Github if I see anything else.

Do I have to use the createContainer method (is this specific to Meteor?), or can I simply generate a container like this: