Is it worth using Redux-Saga in the long term? [closed]
Asked Answered
E

1

9

Redux-Saga, a Redux side effect manager, is said to be deprecated, and no longer being maintained.

Yet, over 1 million developers download this NPM package weekly, regardless of the fact that the last 1.1.3 version of Redux-Saga was published almost 3 years ago.

What issues might I face if I keep on using Redux-Saga for the long term, even if it is no longer being maintained by its authors?

Eocene answered 24/5, 2022 at 9:20 Comment(0)
V
26

I'm a Redux maintainer.

Today, we specifically recommend against using sagas in almost all use cases!

To be clear: Sagas are a great power tool, like a chainsaw. If you really need that power, then having that tool is important. But most of the time, you don't need a chainsaw on a daily basis.

I actually just gave a talk on this specific topic:

Reactathon 2022: The Evolution of Redux Async Logic

In that talk I described different techniques for dealing with async logic and side effects in Redux apps, and gave our set of recommendations for what you should use today. I'll paste in the last slide here for reference:

Our Recommendations Today

What use case are you trying to solve?

Data Fetching

  • Use RTK Query as the default approach for data fetching and caching
  • If RTKQ doesn't fully fit for some reason, use createAsyncThunk
  • Only fall back to handwritten thunks if nothing else works
  • Don't use sagas or observables for data fetching!

Reacting to Actions / State Changes, Async Workflows

  • Use the RTK "listener" middleware as the default for responding to store updates and writing long-running async workflows
  • Only use sagas / observables in the very rare situation that listeners don't solve your use case well enough

Logic with State Access

  • Use thunks for complex sync and moderate async logic, including access to getState and dispatching multiple actions
Vallecula answered 25/5, 2022 at 0:0 Comment(4)
Thank you, indeed. Got it. Yet, the second part of my question was about capability of using a technology, which is no longer being maintained. Not so much what to replace it with.Eocene
@MaksymDudyk : the saga library works fine, and is still maintained - in fact, "it's still maintained" was confirmed in an issue just a few days ago: github.com/redux-saga/redux-saga/issues/2298 .Vallecula
This answer isn't even close to presenting a full picture of comparison. It is rather an advert for RTK query. While mark is right about the daily use cases part, knowing what Redux Saga can do is also important. And I think the original question meant to ask about Redux saga which is not answered.Flippant
@Flippant : I'm not sure you actually read my comment. The literal answer is "don't use it, it's not the right tool in almost all cases, and there's better tools that we recommend". My talk goes into more details, and I recently added a docs page with that expanded information as well: redux.js.org/usage/side-effects-approachesVallecula

© 2022 - 2024 — McMap. All rights reserved.