Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from "react";
- class Recipe extends Component {
- constructor(props) {
- super(props);
- this.state = {
- // See App.js for more details. loadRecipe is defined there.
- recipe: this.props.loadRecipe(this.props.id)
- };
- }
- render() {
- // In case the Recipe does not exists, let's make it default.
- let title = "Recipe not found";
- // If the recipe *does* exists, make a copy of title to the variable.
- if (this.state.recipe) {
- title = this.state.recipe.title;
- }
- return (
- <React.Fragment>
- <h1>The recipe:</h1>
- <p>{title}</p>
- {/* TODO: Print the rest of the recipe data here */}
- </React.Fragment>
- );
- }
- }
- export default Recipe;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement