facebookexperimental / Recoil

Recoil is an experimental state management library for React apps. It provides several capabilities that are difficult to achieve with React alone, while being compatible with the newest features of React.
https://recoiljs.org/
MIT License
19.52k stars 1.18k forks source link

Add unit tests for glitch-freeness #535

Open ziriax opened 3 years ago

ziriax commented 3 years ago

First of all thanks for sharing this amazing library!

I was wondering, is Recoil glitch-free?

Many other reactive frameworks - like RxJS - don't have a synchronous dataflow architecture, so updates happen in the order of subscription, and not per se in the correct dependency order (like FlapJAX, SodiumFRP, Reactive-Banana, etc).

I'm curious if Recoil solves this problem?

mattferrin commented 3 years ago

I feel like a case of convergent evolution. I just learned Recoil exists this weekend. I have been using my own poor man's versions of useRecoilState, useRecoilStateLoadable, and essentially a useRecoilStateLazyLoadable (which Recoil doesn't seem to have as of yet). I love Loadable. My version of Loadable can have an additional "uncalled" state.

I like how the API of Recoil read-ably formalizes things I've only been following as patterns. Recoil also adds waitForAll(), waitForAny(), and waitForNone() (all of which I haven't even thought of writing).

Anyway, I've only ever read and haven't written any RxJS-like-things, but feel like I know enough to answer your question. There is a danger that if you separate hasValue, hasError, and loading states into separate cases that the rendered HTML outputs will have different dimensions and that can cause glitchy-ness. That can be solved by fixing loading skeleton and error output dimensions. Or it can be solved by combining separate states in a way similar to this example from an "article" I wrote.

davidmccabe commented 3 years ago

I believe that Recoil does not suffer from the problem described in the article you linked. It would be a great thing to have tests for!

Cijin commented 3 years ago

Hi, I would love to contribute to this issue. Although would need some directions where I could or should start writing tests for. I've been using recoil for about 3 months now, and would love to contribute. I think this would be a great place to start.

@davidmccabe

Thank you in advance. :)

cghiassi5 commented 2 years ago

I'm not sure If this is still an ongoing issue, but if so I would love to work on unit tests.

drarmstr commented 2 years ago

Sure, we would definitely welcome more tests!