How to set up React in Vite with Laravel.
How to set up React in Vite with Laravel.
Dan Abramov shared a short post on some key principles the React team sticks to. Some solid general advice here, it's not explicitly related to React.
Absorb the Complexity
Making React internals simple is not a goal. We are willing to make React internals complex if that complexity lets product developers keep their code easier to understand and modify.
Hacks, Then Idioms
We need to allow hacks using escape hatches, and observe which hacks people put in practice. Our job is to eventually provide an idiomatic solution for hacks that exist in the name of better user experience. Sometimes, a solution might take years. We prefer a flexible hack to entrenching a poor idiom.
These two stood out because they're the opposite of how I generally need to think when building applications (although they make perfect sense in the context of something like a lower level framework). Either way, lots of food for thought in here.
Read all principles on overreacted.io.
I built a small React component that uses the Google Places API to autocomplete an address in a project I'm working on, and extracted the prediction fetching to a custom
useAddressPredictions hook. It's a nice example of a custom React hook composed of different primisite hooks, so I decided to pen write my thought process while building it.
React follows semantic versioning, but with a twist. From their versioning policy:
When releasing critical bug fixes, we make a patch release by changing the z number (ex: 15.6.2 to 15.6.3).
When releasing new features or non-critical fixes, we make a minor release by changing the y number (ex: 15.6.2 to 15.7.0).
When releasing breaking changes, we make a major release by changing the x number (ex: 15.6.2 to 16.0.0).
The twist is subtle: non-critical bugfixes are released as minor releases.
I've often wondered whether three digits really is necessary for versioning. As a package maintainer, deciding between minor and patch is often a gray area.
Two digits would suffice: breaking changes and non-breaking changes. Feature or bugfix doesn't really matter from a technical point of view: upgrading can either break things, or can't.
React reserves the patch number for critical bugfixes, which I believe is a necessary escape hatch in a two digit system. But I like I how they default to simply bumping minor versions.
React components have always relied on lifecycle methods for side effects. While lifecycle methods get the job done, they're often overly verbose and have large margins for error.
It's easy to forget to "clean up" a side effect when a component unmounts, or update the side effect when props change. As Dan Abramov preaches: Don't stop the data flow.
React recently introduced a new way to deal with side effects: the
useEffect hook. Translating lifecycle methods to
useEffect calls can be confusing at first. It's confusing because we shouldn't be translating imperative lifecycle methods to declarative
useEffect calls in the first place.
For the past three years, I've been using both React and Vue in different projects, ranging from smaller websites to large scale apps.
We covered a lot of ground on the podcast, but most things we talked about could benefit from some code snippets to illustrate their similaraties and differences.
This post is a succinct rundown of most Vue features, and how I would write them with React in 2019 with hooks.
I had the honor to be a guest on Full Stack Radio with Adam Wathan.
We talked about why I prefer React over Vue — which I wrote about two weeks ago — and how to implement some patterns that Vue provides out of the box but aren't explicitly available in React. Examples include computed properties, events and slots.
In this episode, Adam talks to Sebastian De Deyne about learning React from the perspective of a Vue developer, and how to translate all of the Vue features you're already comfortable with to React code.
Tune in on fullstackradio.com or on your favorite podcatcher!
In this article, we reintroduce closures by building a tiny clone of React Hooks. This will serve two purposes – to demonstrate the effective use of closures, and to show how you can build a Hooks clone in just 29 lines of readable JS. Finally, we arrive at how Custom Hooks naturally arise.
Understanding how React deals with hooks internally isn't a required to use them, but it's interesting material nonetheless!
You can read the full article on the Netlify blog.