DEV Community

Discussion on: SERIES: React Native (Step by Step) - Auth Flow Navigation with Mock User Login

Collapse
jerrybels profile image
JerryBels

A question please. Why for the users' duck did you go the separate actions, reducers and so on instead of using createSlice like you showed us for the Counter? I rewrote it using createSlice and I find it much better, more readable (also I used a few createAsyncThunk since I need stuff coming from my api).

Collapse
allbitsequal profile image
Konrad Abe Author • Edited

Hi Jerry.

This is a good question and the answer can't be as straight forward as I would like it to be. In short and from my own experience, using createSlice is the simpler and more easier to use way to do it, which also comes with better readability. If you can rewrite a case using createAction and createReducer with no issues, this is a good option.

For me it came as a personal choice which I could have explained better in the article so thanks for pointing this out. I prefer to go the "manual" way because I often have custom payloads and integrate middleware for my ducks which is "at least for me" more convenient and better to read when using separate action creators and reducer creators.

I personally chose not to use Thunks, Epics or other prebuilt middleware solutions so my requirements might vary a bit from yours.

I will try to update the article soon to reflect this in more detail.

Collapse
jerrybels profile image
JerryBels

Very interesting answer! As a beginner in React and affiliates, I really enjoyed learning things with your article. Thanks and have a good day :)