react 2020-09-09

So for the last few weeks, we have been using Reseda in anger. It’s actually quite nice 😄 Clojure atoms for the win.

I’m hoping to find some time to writer a proper README and announce it.

👏 2

That's great :D

I learned something surprising recently, I've been meaning to mention it here, because I feel like I might be wrong. set-xxx from useState isn't transactional! It causes an immediate re-render before continuing onto further statements

We were getting errors from impossible states because we had functions calling (set-xxx 10) (set-yyy 20)

hmm yeah, I think there’s a version of React where batching is enabled. or you can maybe enable it now?

Oh, you have to globally enable it? Interesting that it's like that.

That sounds wrong to me @dominicm

Inside event handlers state changes are batched

I didn't believe it either, but it was happening. I added logs to the render to prove that it was changing between the set state calls.

> “Currently (React 16 and earlier), only updates inside React event handlers are batched by default” , according to https://stackoverflow.com/questions/48563650/does-react-keep-the-order-for-state-updates/48610973#48610973.

For doing manual batching there’s an unsafe prefixed function you can call.

Ah. We maybe weren't in a react event handler.

Logging inside renders is also unsafe :)

Try tap or something that doesn’t use console.log and you’ll see double renders.

yeah that’s so silly they did that

I think that’s only in CM

in concurrent mode + dev bundle, React will render your component twice to force you to make your code concurrent-mode safe

during the second render, they actually monkey patch console.log to avoid logging things twice 😵

which IMO makes CM bugs that much harder to catch

No no no no no 😢

OK, I have a first round of docs in: https://github.com/orestis/reseda — any kind people that would do a proofread?

I’m actually heading to bed 😄

I like this a lot. looks simple and the README examples are illustrative

It’s super simple. The useStore is mainly copied from the use-subscription package and made a bit more Clojurey. The useSuspending is hairy but seems to work fine.

There’s no more promises or callbacks in our UI code. It’s super nice.

Looks ok to me, cursory read though