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"> Â Â Â Â Â Â Â ...