My previous post included this paragraph: let vs const vs var : Usually you want let . If you want to forbid assignment to this variable, you can use const . (Some codebases and coworkers are pedantic and force you to use const when there is only one ... more
During my first few years of using JavaScript, I felt like a fraud. Even though I could build websites with frameworks, something was missing. I dreaded JavaScript job interviews because I didn’t have a solid grasp on fundamentals. Over the years, I’ve ... more
If your JavaScript codebase is even moderately complex, you probably have a way to bundle and run different code in development and production . Bundling and running different code in development and production is powerful. In development mode, React ... more
Have you heard about algebraic effects ? My first attempts to figure out what they are or why I should care about them were unsuccessful. I found a few pdfs but they only confused me more. (There’s something about academic pdfs that makes me sleepy.) ... more
You’ve discovered something new. You haven’t seen solutions quite like this before. You try to keep your ego in check and be skeptical. But the butterflies in your stomach won’t listen. You don’t want to get carried away, but deep down you already know ... more
When people start learning React, they often ask for a style guide. While it’s a good idea to have some consistent rules applied across a project, a lot of them are arbitrary — and so React doesn’t have a strong opinion about them. You can use different ... more
You wrote a few components with Hooks. Maybe even a small app. You’re mostly satisfied. You’re comfortable with the API and picked up a few tricks along the way. You even made some custom Hooks to extract repetitive logic (300 lines gone!) and showed ... more
How do React function components differ from React classes? For a while, the canonical answer has been that classes provide access to more features (like state). With Hooks, that’s not true anymore. Maybe you’ve heard one of them is better for performance. ... more
Most tutorials introduce React as a UI library. This makes sense because React is a UI library. That’s literally what the tagline says! I’ve written about the challenges of creating user interfaces before. But this post talks about React in a different ... more
If you played with React Hooks for more than a few hours, you probably ran into an intriguing problem: using setInterval just doesn’t work as you’d expect. In the words of Ryan Florence: I’ve had a lot of people point to setInterval with hooks as some ... more
When you write performance-sensitive code, it’s a good idea to keep in mind its algorithmic complexity. It is often expressed with the Big-O notation. Big-O is a measure of how much slower the code will get as you throw more data at it . For example, ... more
Duyduğuma göre Hooks en çok konuşulan yenilik olmuş. İronik olarak, bu bloğu class bileşenleri hakkında bilinmeyen gerçekleri açıklamak için açmak istedim. Burda anlatılanlar, React’ı üretken olarak kullanmak için çok da önemli değil . Ancak bir şeylerin ... more
In my previous post, I talked about admitting our knowledge gaps. You might conclude that I suggest settling for mediocrity. I don’t! This is a broad field. I strongly believe that you can “begin anywhere” and don’t need to learn technologies in any ... more
People often assume that I know far more than I actually do. That’s not a bad problem to have and I’m not complaining. (Folks from minority groups often suffer the opposite bias despite their hard-earned credentials, and that sucks .) In this post I’ll ... more
At React Conf 2018, the React team presented the Hooks proposal. If you’d like to understand what Hooks are and what problems they solve, check out our talks introducing them and my follow-up article addressing common misconceptions. Chances are you ... more
When you call setState in a component, what do you think happens? import React from 'react'; import ReactDOM from 'react-dom'; class Button extends React.Component { constructor(props) { super(props); this.state = { clicked: false }; this.handleClick ... more
Do you have a project that you approach repeatedly with a mix of success and failure, step aside for a while, and then try again — year after year? For some, it might be a router or a virtual list scroller. For me, it’s hot reloading. My first exposure ... more
You might think you’re writing JSX: <marquee bgcolor="#ffa7c4">hi</marquee> But really, you’re calling a function: React.createElement( /* type */ 'marquee', /* props */ { bgcolor: '#ffa7c4' }, /* children */ 'hi' ) And that function ... more
You might think you’re writing JSX: <marquee bgcolor="#ffa7c4">hi</marquee> But really, you’re calling a function: React.createElement( /* type */ 'marquee', /* props */ { bgcolor: '#ffa7c4' }, /* children */ 'hi' ) And that function ... more
Consider this Greeting component which is defined as a function: function Greeting() { return <p>Hello</p>; } React also supports defining it as a class: class Greeting extends React.Component { render() { return <p>Hello</p>; ... more
Consider this Greeting component which is defined as a function: function Greeting() { return <p>Hello</p>; } React also supports defining it as a class: class Greeting extends React.Component { render() { return <p>Hello</p>; ... more
I heard Hooks are the new hotness. Ironically, I want to start this blog by describing fun facts about class components. How about that! These gotchas are not important for using React productively. But you might find them amusing if you like to dig ... more
I heard Hooks are the new hotness. Ironically, I want to start this blog by describing fun facts about class components. How about that! These gotchas are not important for using React productively. But you might find them amusing if you like to dig ... more