I usually write about what I made and learned, but this time, I wanted to share knowledge I gained from other people. I think these 3 articles and 1 documentary will help you become a better web developer.
CSS rules are
frustrating are a nightmare. What is even more frustrating are behaviors that are not well documented. One of these are CSS margins. Here’s an example: did you know margins only collapse vertically?
Thankfully, Josh Comeau has written all the weird arbitrary rules that margins have. I personally won’t be using margin unless it’s for one-off spacing that Flexbox gap wouldn’t work for.
React re-renders are hard to tame. Any state change in a component will propagate re-renders to all its children components. You may already know some ways to isolate re-renders:
- Move state down
- If state can’t be moved down, use a global state management with atomic picks to isolate re-renders
- Pass the component as a prop or children
There’s also React.memo but TkDodo warns against using it for very good reasons. For example, using inline props can easily break it since inline functions and objects are recreated when the component re-renders.
Operating without Foreign Key Constraints by Planetscale
This article is from the Planetscale’s documentation, which is a MySQL serverless database service. Planetscale explains it doesn’t support foreign key constraints because it interferes with Online DDL operations and it becomes harder to maintain over multiple database servers. By enforcing referential integrity at the application level instead of at the database level, Planetscale can benefit from online DDL and unlimited scaling through sharding.
Initially I thought this was a weird approach but I agreed with it after reading through the page. I love it when developers rethink best practices.
Speaking of rethinking best practices, this 76 minute documentary goes into the origin and early public reception to React when it was released as open source. The initial reception was extremely negative; people hated JSX and thought React broke separation of concerns.
Thankfully, early adopters started using React, few in production, and an open source community quickly grew around React, which the React team cultivated by fixing bugs, releasing new features, and organizing meetups. I found this documentary inspiring for two reasons.
- I’m now a full stack engineer with a year of professional experience under my belt and I have spent almost all of my time deferring to other people’s opinions on how things should be built. And I should since I don’t know much. But now as I gain more experience, I am starting to become more opinionated. And the fact that traditional best practices have been broken and innovated upon gives me confidence to experiment and try out new approaches.
- The strength of the open source community makes me want to contribute to open source projects. I think it’s beautiful to see really smart people passionately work together for no compensation just because they love building cool things. And I want to be part of that.