Over the weekend and this morning, I finished implementing the new state architecture so we are now using Redux for global state and each feature has a container that holds the state for the feature and passes it down via Context. I did put the feature state into Redux, but that may have been a mistake. I may undo that and bring it back to be local state for the feature container.
Thad and I also got a lot done for DevLifts — fitStart month 2 plans started going out, we ran some numbers to see how the past month went with web traffic, and we implemented some neat new discounts. 😃
Today, I spent a lot of time thinking about our component tree and refactoring all the code I had written for my new feature at Trinity. I also started [finally] writing new components — hoping to finish the UI tomorrow and Wednesday and then go back and make it all stateful.
Today I Learned
There’s no great way to delay the unmounting of a React component…
I needed to make a Loading component show for at least 2 seconds, even if the data was already back from the API and loaded into the store. Weird, I know, but it was a UX requirement and there’s actually a business case for it in our particular instance.
I reached for
componentWillUnmount and quickly figured out that the component is still going to unmount and there’s no way I can really stop it from doing that in
I ended up doing something really hacky: I set a loading state in the feature container, and then set up a function to create a Promise and resolve it after 2 seconds. When I need that loading component to render, I just set the
loading state to true and then fire the Promise function. When it resolves, it sets the
loading state back to
Stupid, I know. But it worked.
Here’s a few links to things I’ve read, watched, or listened to:
- What is MDX? – Video by Kent C. Dodds
- Stop Squatting Like This – Great video from AthleanX
- RxJS and redux-observable with Tracy Lee, Jay Phelps, and Ben Lesh – Great episode from React Round Up
- Update on Async Rendering – this is gonna be insane 🔥
- Sneak Peek: Beyond React 16 – great talk from Dan Abramov about Async Rendering features coming to React!