jsparrow.uk

React: 3 Simple Projects
04 March 2020

React: 3 Simple Projects

Over the past few weeks, I have made an effort to develop my frontend skills by learning a frontend JavaScript framework. I decided on react.js as it’s currently the most popular frontend framework and also has the benefit of integrating with Laravel, even though Laravel uses vue.js by default. React took a little while to get my head around, and I still have a lot I want to learn and do with it, including adding react components to my Laravel web apps (such as jsparrow.uk and HanziBase). After about 2 weeks, I have created 3 small projects as I have been learning react.

Todo List (React with Redux)



I know, pretty boring sounding. This was actually the first react app I created, and eventually after learning about state management and redux, I wanted to give it a try. So, I took my first react app and added some redux to it. The state of the todo’s is now managed by the global store, and all the boiler plating for the redux was written by me. It also features a clock which keeps track of the page’s uptime, not super useful but still novel enough to leave in. You can check it out here if you’re interested or simply take a look at the GitHub repository here.

Meme Generator (End of course project)



I first started learning react using this 5 hour course on the freeCodeCamp Youtube channel. The end of course project in this is a meme generator, which uses a react form to get input two strings, one for the top text of the meme and the other for the bottom text. A request is then sent to imgflip to get a meme image and save it in the state. The text is then overlaid on the image and the user can make some funny memes. Sometimes the imgflip API provides an image which expects a different format and the meme doesn’t look very good, so a button to get a new image is on the form just in case a bad image is provided. The GitHub repository is here and you can view it live here.

SWbrowser (Fetch API, React Router, Hooks)



This project used the Star Wars API to grab data about the characters, planets and ships from the Star Wars films. It is a multipage web app completely in react, which brought about some new challenges I had not encountered until now. For example, what happens when a fetch request is sent off but before it has the chance to return the promise, the user switches to another part of the application? I eventually fixed this issue with the abortController API. The routing is handled by the react router, and the app utilizes error catching as well as both functional and class-based components. The functional components use hooks such as useState and useEffect hooks to manage the state. You can check it out here or find it on GitHub here.

Next Steps

Now that I have some very basic react apps under my belt, I will be looking into integrating react into my Laravel apps, as well as doing a more substantial react app (maybe with redux) in the near future. I’m not sure what this will be yet, but I have a few ideas, such as a weather or recipe management app. I might have a look and see what API’s I could use to make such an app and make a decision from there.