4 Things I Have Read That Are Good for Web Devs
Tags: react, webdev, frontend, fullstack
Published: 2023-11-16 00:32:42

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.

### [Rules of Margin Collapse](https://www.joshwcomeau.com/css/rules-of-margin-collapse/) by [Josh Comeau](https://twitter.com/JoshWComeau)

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?


![Horizontal margins do not collapse](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fey38esww3eikxu2x00i.png)

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.

---

### [The Uphill Battle of Memoization](https://tkdodo.eu/blog/the-uphill-battle-of-memoization) by [TkDodo](https://twitter.com/tkdodo)

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:

1. Move state down
    1. If state can’t be moved down, use a global state management with atomic picks to isolate re-renders
2. 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](https://planetscale.com/docs/learn/operating-without-foreign-key-constraints#how-does-your-schema-look-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.

---

### [How a Small Team of Developers Created React at Facebook | React.js: The Documentary](https://www.youtube.com/watch?v=8pDqJVdNa44) by Honeypot

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](https://youtu.be/8pDqJVdNa44?t=2208); people hated JSX and thought React broke separation of concerns.


![React doubters tweet about JSX](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lxt6uuqql83jqub3mzjy.png)


![React doubters tweet about separation of concerns](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m23e4n9flcjo6q0z758z.png)

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. 

1. 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.
2. 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.