14. Fetching Data by Making API Requests
Activity 14.01: Building an App to Request Data from Unsplash
Solution
- Install
create-react-appfor the project namedsearch-unsplash-images. - In the
srcfolder, create a file calledindex.jsand add the following code. It will import the<App>component and render it in HTML:import React from 'react'; import ReactDOM from 'react-dom'; import App from './components/App'; ReactDOM.render(<App />, document.querySelector('#root')); - Still in the
srcfolder, create another file calledApp.jsand add some boilerplate for the<App>component:import React, { Component } from 'react'; class App extends Component { Â Â render() { Â Â Â Â return ( Â Â Â Â Â Â <div className="page"> Â Â Â Â Â Â Â Â <div className="box"> Â Â Â Â Â Â Â ...