React.createElement
Conversion type | JSX | JavaScript |
---|---|---|
tags | <h1></h1> |
React.createElement('h1', null) |
attributes | <img src="foo.png"/> |
React.createElement('img', { src: "foo.png" }) |
variables | <h1>{message}</h1> |
React.createElement('h1', null, message) |
HTML | self-closing tag JSX equivalent |
---|---|
<br> |
<br /> |
<hr> |
<hr /> |
<img> |
<img /> |
<input> |
<input /> |
<link> |
<link /> |
import React from 'react';
const PostList = (props) => {
return (
<ul>
{props.posts.map(post => (
<li key={post.id}>
{post.body} by: {post.user}
</li>
))}
</ul>
)
};
Install create-react-app
globally (if you don’t have it already):
npm install -g create-react-app
Make a boilerplate React project with create-react-app
:
npx create-react-app <project folder name>
Use App Academy’s simple template for create-react-app
:
npx create-react-app <project folder name> --template @appacademy/simple
Part 1 - Remove unnecessary boilerplate code that comes with create-react-app
Part 2 - Navigation component
Part 3 - PetDetails components
Part 4 - OwnersList components