function Product() {
}
===== Return markup =====
Each component must return a value. We create a
function Product() {
return (
Product Name
Product Description
$20
);
}
===== Export the component =====
Now we have a component. But if we want to use it in other files, we need to export the function. To export a component, you need to add the keywords "export default" before the function declaration. This will mark the function to be exported. Now you can include the file in another file to use this component.
Product.js
export default function Product() {
return (
);
}
ProductsList.js
import Product from './Product.js';
export default function ProductsList() {
return (
Our Products
);
}