After learning & doing a few tutorials/courses on React for a few days, I wanted to build a fun web app, to not only work with components, but also to see, how to fetch data from a third-party database via API, how to display it and how to add different details with React.
Originally, I wanted to use another database, but I switched mid way through, because I didn't liked the content the initial chosen database provided. With that, I needed to adapt the functionality a bit.
User stories
The user:
- sees a simple interface on load
- can hit a button to get random Chuck Norris facts
- can tweet a chosen Chuck Norris fact
- can set a few different settings to tweak the results
- set up react-app using
create-react-app
- deploy with simple "nothing to see"-interface
- set up interface with dummy components
- fetch data and display it in the Fact component
- sketch out component tree
- start from scratch
- render simple UI with Chuck Norris portrait & "hit me" button
- implement "hit me"-function & render hard coded Fact component
- add Tweet function via Tweet Web Intent
- fetch data from database & display within Fact component
- fetch multiple random facts & display Facts with
.map()
- add counter, so user can set the number of fetched facts
- add settings, where the user can change the name used in the fact, limit the results to "nerdy only" facts
- add buttons at the bottom to fetch more random facts and to clear the ui
- style everything with external stylesheet (plain CSS)
- in general getting comfortable with using React & JSX
- how to split the user interface into different React components, as well as refactoring code into separate components
- how to fetch data using the Fetch-API
- how to conditionally display components
- make settings form responsive
- refactor code, maybe the settings form in a separate component
- implement Typechecking with PropTypes
-
smooth out the transition of the settings menu when opened/closed →CSSTransition
/TransitionGroup
-
currently the Tweet function is not accessible by keyboard only navigation, it's something, I want to implement as well
This project was bootstrapped with Create React App.
You can find the most recent version of the guide here.
-
Facts fetched from ICNDb.com
-
Dancin' Chuck Gif jesgrad07 on DeviantArt
-
Favicon made by Freepik from www.flaticon.com (licensed by CC 3.0 BY)
-
Background Picture by Jean-Pierre Brungs via Unsplash