DEV Community

Discussion on: 5 Ways SolidJS Differs from Other JS Frameworks

 
ryansolid profile image
Ryan Carniato

It's interesting, to think we might be able to locally apply changes without committing them to the outside world even in this scenario. It does bring a little bit of complexity. Observing the past like React feels a lot more consistent on the other side. The problem with Async consistency/Concurrent Rendering is that outside of the processing scope you have to be witnessing the past because it hasn't happened yet..

Solid has a transition API for this which uses batching under the hood. This is probably a little bit out there unless you are super familiar with future React features.

console.log("1", signalThatTriggersAsyncFetch()); // oldData
startTransition(() => {
  setSignalThatTriggersAsyncFetch(newData);
  console.log("2", signalThatTriggersAsyncFetch()); // oldData? newData?
});
console.log("3", signalThatTriggersAsyncFetch()); // has to be oldData;
Enter fullscreen mode Exit fullscreen mode

Right now Solid will show oldData for all 3 in synchronous executation, but if we immediately updated in local scope .. we'd see:

1 oldData
2 newData
3 oldData
Enter fullscreen mode Exit fullscreen mode

This is a bit confusing. Especially if something causes this transition to be cancelled and never complete. I'm not saying I can't be talked out of this behavior but it was a very safe position to take. And really only React seems to have really given this sort of thing consideration.