⚠️ This lesson is retired and might contain outdated information.

Generate a Page Using the Redwood CLI

Ian Jones
InstructorIan Jones
Share this video with your friends

Social Share Links

Send Tweet
Published 5 years ago
Updated 2 years ago

We use yarn redwood generate page (yarn rw for short) in this lesson to generate an IndexPage component.

The first argument to yarn rw generate page is the name of the page you are generating. The second argument is the path you want the page to show up on. So yarn rw generate page index / will generate an IndexPage component and insert a route entry in our web/src/Routes.js file.

We learn that redwood import React for you so you don't have to import it manually when you are creating a component.

Instructor: [0:00] Right now we have a default empty Redwood project. As you can see in our routes, all we have is the not found page.

[0:08] To generate a new page, open up a new terminal and we'll use the Redwood's CLI to generate a new index page. We'll call Yarn Redwood. You can use rw for short, generate page. This tells Redwood to generate a page component. The first argument is the name of the page that we're generating. In this case, index.

[0:35] The next argument is the path we want the page to be on. Since we're generating an index page, we want it to be on our root path.

[0:46] Redwood generated an index page test file and the index page and updated our routes. If we go over to our routes, you can see that Redwood inserted a route with the path that we passed in and the component. You can see that Redwood generated a component called index page. This is a convention where all of the pages are appended with the word page.

[1:18] If we go over to our file, you'll notice that React is not imported. That's because Redwood decided that they will import React for you. If we modify this and we say hello egghead. When we go to our browser, we'll see that we have index page and hello egghead.

egghead
egghead

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today