14. Fetching Data by Making API Requests
Activity 14.01: Building an App to Request Data from Unsplash
Solution
- Install
create-react-app
for the project namedsearch-unsplash-images
. - In the
src
folder, create a file calledindex.js
and 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
src
folder, create another file calledApp.js
and add some boilerplate for the<App>
component:import React, { Component } from 'react'; class App extends Component { render() { return ( <div className="page"> <div className="box"> ...