For this intro to react, we are going to build a Joke Generator
DO NOT worry about style until you get the initial functionality together. This is a lightning exercise, so it is meant to be completed in 30 minutes or less.
Make a quick plan and then execute it.
- When a user first loads the app, a button appears on the DOM that reads "Get a Joke"
- When the user presses the "Get a Joke" button, an API call is made to the joke API and the joke setup appears on the DOM.
- When a user presses the "Get a Joke" button, the button text changes to "Get Punchline"
- When a user presses the "Get Punchline" button, both the joke setup and delivery are on the DOM along with a button that reads "Get Another Joke"
- When the user presses the "Get Another Joke" button, the app starts over from step 2.
- API Documentation
- Get the Postman Collection
- In Postman, select "Import" > "Link"
- Copy/Paste this link into the input:
https://www.getpostman.com/collections/548ed97710101a76aa64
- Click "Import"
DO NOT complete any stretch goals until the functionality of the application is completed.
- Styling the app
- View the mock
DO NOT COPY AND PASTE. Type out every line of code. Try working the code yourself and only use this as a reference
There are 3 button states in our application:
- Initial State: Get A Joke
- Get Punchline
- Get Another Joke
CODE: Button State Changes
There are 3 Joke states in our application:
- Initial State: No joke
- Joke Setup
- Joke setup and joke punchline
CODE: Joke State Changes