redux-thunk

Property 'then' does not exist on type 'AsyncThunkAction' Redux-toolkit

旧城冷巷雨未停 提交于 2021-01-28 19:07:20
问题 I can't seem to receive a Promise from createAsyncThunk function from Redux-toolkit I'm fairly new to Typescript and I'm struggling to figure out why it's giving me Property 'then' does not exist on type 'AsyncThunkAction<Student, number, {}>' error even though the promise does get returned if I remove the typing. Here is my createAsyncThunk f-n export const getStudentByIdRequest = createAsyncThunk<Student, number>( 'student/getStudentByIdRequest', async (id, { rejectWithValue }) => { try {

React Redux sync action returns some Proxy object instead of string

一笑奈何 提交于 2021-01-28 09:01:57
问题 I have an input with currentAnswer : <input value={props.currentAnswer} onChange={(text) => dispatch(onChangeAnswer(text))} /> Which calls function onChangeAnswer : export function onChangeAnswer(text) { console.log(text); return { type: ON_CHANGE_ANSWER, data: text }; } Reducer: export default function reduce(state = initialState, action) { switch (action.type) { case ON_CHANGE_ANSWER: return assign({}, state, { currentAnswer: action.data }); Async actions works good, but when I change text

react-redux-firebase error 'Firebase instance does not yet exist. Check your compose function.'

喜欢而已 提交于 2021-01-27 23:32:33
问题 I'm using 'react-redux-firebase' in my project and want to integrate firebase into react-thunk. Everything works fine on local but I got error when deploy project to Firebase hosting. Uncaught Error: Firebase instance does not yet exist. Check your compose function. What is the problem here? store.js import { createStore, compose, applyMiddleware } from 'redux'; import thunk from 'redux-thunk'; import { reduxFirestore, getFirestore } from 'redux-firestore'; import { reactReduxFirebase,

How to return a promise from an action using thunk and useDispatch (react-redux hooks)?

旧巷老猫 提交于 2021-01-26 07:36:39
问题 I just started exploring react-redux hooks and I was curious how to return a promise if I am using thunk and useDispatch() . Essentially I want to achieve the following: const dispatch = useDispatch(); dispatch(myAction(...args)).then((result) => { ...do something with result }); When my action looks like this: const myAction = (arg1, arg2) => { return (dispatch, getState) => { Promise.resolve(arg1 + arg2); } } I've simplified my problem a lot, but that is essentially what I'm dealing with.

How to return a promise from an action using thunk and useDispatch (react-redux hooks)?

喜你入骨 提交于 2021-01-26 07:35:52
问题 I just started exploring react-redux hooks and I was curious how to return a promise if I am using thunk and useDispatch() . Essentially I want to achieve the following: const dispatch = useDispatch(); dispatch(myAction(...args)).then((result) => { ...do something with result }); When my action looks like this: const myAction = (arg1, arg2) => { return (dispatch, getState) => { Promise.resolve(arg1 + arg2); } } I've simplified my problem a lot, but that is essentially what I'm dealing with.

How to return a promise from an action using thunk and useDispatch (react-redux hooks)?

a 夏天 提交于 2021-01-26 07:35:11
问题 I just started exploring react-redux hooks and I was curious how to return a promise if I am using thunk and useDispatch() . Essentially I want to achieve the following: const dispatch = useDispatch(); dispatch(myAction(...args)).then((result) => { ...do something with result }); When my action looks like this: const myAction = (arg1, arg2) => { return (dispatch, getState) => { Promise.resolve(arg1 + arg2); } } I've simplified my problem a lot, but that is essentially what I'm dealing with.