How to divide the logic between Redux reducers and action creators?

Your reducer must be pure. Currently it is not pure. It calls deal() which calls getRandom() which relies on Math.random() and thus is not pure. This kind of logic (“generating data”, whether randomized or from user input) should be in the action creator. Action creators don’t need to be pure, and can safely use Math.random(). … Read more

Using redux-form I’m losing focus after typing the first character

This happens because you’re re-defining renderField as a new component every time you render which means it looks like a new component to React so it’ll unmount the original one and re-mounts the new one. You’ll need to hoist it up: const renderField = ({ input, label, type, meta: { touched, invalid, error } }) … Read more

Redux ToolKit: is it possible to dispatch other actions from the same slice in one action created by createAsyncThunk

Possibly it’s not actual and the question is outdated, but there is thunkAPI as second parameter in payload creator of createAsyncThunk, so it can be used like so export const updateData = createAsyncThunk(‘data/update’, async (params, {dispatch}) => { const result = await sdkClient.update({ params }) dispatch(getData()) return result })

Cannot set getState type to RootState in createAsyncThunk

The createAsyncThunk can have the types defined on the generics: export const unsubscribeMeta = createAsyncThunk<apiUnsubscribeResponse, void, {state: RootState }>( ‘meta/unsubscribe’, async (_, { getState }) => { const { meta } = getState(); const res = await client.post<apiUnsubscribeResponse>( `/meta/unsubscribe/${meta.subscriptionId}` ); return res.data.data; } ); Defining the state will automatically make the getState be aware of … Read more

Where should I handle sorting in Redux App?

IMO, the right place to sort data is not directly in the reducers but in the selectors. From redux docs: Computing Derived Data Reselect is a simple library for creating memoized, composable selector functions. Reselect selectors can be used to efficiently compute derived data from the Redux store. I’m currently using selectors to filter and … Read more

How to “yield put” in redux-saga within a callback?

One possible solution, as you already mentioned, is to use channels. Here is an example that should work in your case: import { channel } from ‘redux-saga’ import { put, take } from ‘redux-saga/effects’ const downloadFileChannel = channel() export function* loadFile(id) { … const download = RNFS.downloadFile({ … // push `S_PROGRESS` action into channel on … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)