Sporum: A Ruby on Rails, React project

Mark Quayle
3 min readApr 1, 2022

The first and largest obstacle to creating this application was the learning of Redux. Redux was an optional part of a previous phase of learning that I did not have time to get to at that point. I wanted to add a complexity to this project so I dove into learning how to use Redux from the beginning. A new way (for me) to create and manipulate State.

Previously using useState to create state and add a starting value to state was how I had to do it. After doing this twenty to one hundred times it was drilled into me pretty well. I had a good idea how to create and pass down state from the top layers down to any layer that it was needed. I understood how to do this but this method is much more prone to error than Redux. Redux gives every component access to state with an import instead of having to pass everything down as a prop. This makes passing things from lower to higher levels much simpler.

There are three principles to Redux.

There must be one single source of truth. This creates one place to look for errors, one place to manipulate to change how things are stores, one place to worry about for all things concerning state. If you do not have to pass things down 5 or 6 times through layers of the tree and instead of a single space that can connect to all branches it simplifies how you work both with the successes and the failures of typical coding.

State is read only. You aren’t ever writing directly to state instead an action has to happen for state to change. Again keeping things simple for debugging and debugging is about 80% of coding.

The functions used to manipulate state are pure functions. Pure functions will always give the same return given the same arguments. When using these functions they take in the old state and return a completely new state apposed to editing the old state.

In this application I used both Redux for the biggest CRUD aspects and also used useState just to have a clear show of understanding both. When showcasing skills I figured it would be best to showcase multiple ways to handle state.

Something I am beginning to understand pretty well is error handling. I changed my method for error handling, instead of creating individual rescues in each controller I created one rescue at the top layer, application controller, this made everything more consistently handled. Instead of creating a custom message on the front end I allow the message to be loaded from the server and displayed as was intended.

Learning and implementing new things has gotten easier. Understanding how to learn is always a difficulty when learning a new thing. The process changes and adapting is always different. Seeing something new now isn’t a completely foreign experience and instead leaves a few moments of confusion as apposed to being completely overwhelmed and feeling like I’m starting over. It’s all addition to a base I already have instead of a new base I have to construct. Keeping it in perspective is always helpful.

--

--

Mark Quayle

This blog will just be about programming. Technical, research, thoughts, whatever may come to mind.