- Some how getting user feedback eg: typing a term in the search bar
- Once search term is retrieved, how to use that term to make a request to an external API
- Use a free API to match the search term and return the results
- How to render the list onto the browser display
-
Create SearchBar Component responsible for just showing text at top of screen
- will handle the typing event
-
Create PhotoList Component responsible for rendering a list of photos on the screen
-
Will still have an App Component(most root)
-
A couple of different Components will end up in the App Component
-
Those different Components will have different CSS files
-
Will not define App Component in
index.js, it will be created in a Component file under /components -
Add a touch of styling to the input search bar with semantic ui
- How to handle user input in the search bar
- Different event Property names eg:
| EVENT | PropertyName |
|---|---|
| CLICK | onClick |
| CHANGE | onChange |
| SUBMIT | onSubmit |
-
After user presses enter key from typing in the search bar, trigger search
-
Show images on the screen
-
Detect when user presses enter key
-
SearchBar Component isn't responsible to make fetch request
-
App Component should make API request and get list of images
-
Take search term and pass it back up to the App Component
-
Where to initiate to attempt fetching images
-
PROPs system allows info to be passed down from Parent to Child(ren)
-
When user hits enter, fetch images
-
Turn App Component to class-based Component
-
In App define CB name onSearchSubmit, passed down to SearchBar
- User submitted the form? Better call the CB to tell App(this.onSearchSubmit)
-
Reference Prop to Child component
#Fetch Data
-
The application is running inside the user's browser
-
Enter search term and hit enter, make AJAX/Network request to an API
-
Issue network request from Photos application
-
Implement Axios
-
Modify onSearchSubmit to call Axios function
-
Use Axios and Unsplash doc to make request to API
-
Console log some images
-
How to get data out of request
-
Render list of images
-
Short-term goal: app will display the number of photos fetched
- Component renders itself one time with no photos list
- onSearchSubmit method called
- Request made to Unsplash ---WAIT---
- Request is complete
- Set photo data on State of App Component
- App Component re-renders and shows photos!
-
After getting response, set it on App Component State
-
Add State in App Component/initialize
-
Fix TypeError with 1 of 3 methods
-
Code cleanup around Axios code, remove configuration from App Component
-
Create PhotoList Component
-
Call PhotoList in order to render out the photos that were fetched(communicate)
-
Loop over all the photos from the returned array and return Brand New Component
-
woohoo!!!!!! the searched photos are returned!!!!!!