I don’t know about you, but when I started writing React apps, I struggled to decide where my state should go. No matter how I re-arranged setState calls, things never felt quite right.
"Messy state"
And maybe that is why I got so excited when I found Redux. Redux gave me a single place to put all my state. Which sounded great in theory.
"What if"
But then I realised that having one spot to put things doesn’t necessarily make them easy to get to.
"Still messy"
It turns out that I needed more than just a place to put things. I also need a system for putting them in the right place.
"Banzai!"
For me, that system came from splitting my state into five categories. It turned the problem of deciding “how does this piece of state relate to all the other state”, into the problem of deciding “what type of state is this”. And as it turns out, this is a whole lot easier.
Continue reading →
A while back, I received a great question from a reader:
Just a note in your Learn React By Itself tutorial. In the “Components” section, where you say:
return (
React.createElement('li', {className: 'Contact'},
React.createElement('h2', {className: 'Contact-name'}, this.props.name)
)
)
It’s not clear to me why you need the parens and can’t just do return React.createElement. I tried that and it fails but I can’t see why. Isn’t typeof x === typeof (x) in JavaScript?
And while it is true that typeof x === typeof (x), the same doesn’t always hold for return. Why?
Continue reading →
I browsed the Truly Ergonomic
But support sounds truly lethargic
I wanted the Keyboard IO
But manufacture is too slow
I trailed the Filco Ninja
With staggered keys which may cause injure
So stuck with Kinesis Advantage
Somewhat like an unwilling hostage
As jamming shift causes excitement
And coloured keys make Colemak blighted
But faced with carpal tunnel syndrome
I’ll gladly take stockholm syndrome
Welcome back to the second instalment of State of React! In case you missed it, the first instalment demonstrated a small app without component state. And it received a bunch of interesting responses, like this one from @metapgmr:
using props as state and claiming that components are … stateless! The React Emperor has no clothes
Yes, the app was basically wearing its birthday suit. And yes, the app did contain state. But no, the state wasn’t in the props – and it wasn’t component state either.
So what was it?
Continue reading →