Заголовок
react class api fetch json
WEB

import React, { Component } from 'react'
import RecipeList from './components/RecipeList
export default class test extends Component {
  constructor(props) {
    super(props)
    this.state = {
      apiResponse: [],
    }
  }
  componentDidMount() {
    fetch(`https://api.myjson.com/bins/t7szj`)
      .then(data => data.json)
      .then(apiResponse => this.setState({ apiResponse }))
  }
  render() {
    return (
      <div>
          <RecipeList recipes={this.state.recipes}>
      </div>
    )
  }
}

 

https://medium.com/better-programming/lets-learn-react-hooks-and-context-api-by-building-a-recipe-search-app-63be9d9e1801


Теги: