score:-2
Thunks return functions, not promises. For this you could look at redux-promise
. But to be honest if your doing something this complex you would be much better off using redux-saga
.
Another approach would be to use the concepts behind redux-api-middleware
to create your own custom redux middleware. I have done this in the past to connect a message queue to redux.
score:0
AppThunk<Promise<void>>
You need to explicitly declare the AppThunks return type, which in this case should be a Promise
containing nothing. You have already made it async so just make sure to enter the correct AppThunk return type
export const signInWithEmailAndPassword = (email: string, password: string): AppThunk<Promise<void>> => {
return async (dispatch) => {
// do stuff
}
}
score:1
Just add return
before this line:
auth.signInWithEmailAndPassword(email, pasword).then(response=>{
So it would be:
export const signInWithEmailAndPasword =(email:string, pasword:string): AppThunk=>{
return async (dispatch)=>{
return auth.signInWithEmailAndPassword(email, pasword).then(response=>{
It should work.
Source: stackoverflow.com
Related Query
- How to return a promise from redux thunk action and consume it in component
- How to return a promise from an action using thunk and useDispatch (react-redux hooks)?
- How do we return a Promise from a store.dispatch in Redux - saga so that we can wait for the resolve and then render in SSR?
- How do i dispatch a redux action from class and not component
- How to dispatch Redux action from stateless component when route is loaded?
- Redux thunk: return promise from dispatched action
- how and when to call a react component methods after state change from redux
- How to use useEffect hook properly with array dependency. I passed state from redux store and still my component renders infinitely
- Return promise from React Redux Thunk
- Redux Toolkit w/ TypeScript: how can I properly type the return value from an async thunk
- How to wait for a Redux action to change state from a React component
- How to add action to functional component using Redux and ReactJS
- Dispatch async redux action from non-react component with thunk middleware
- How to take parameters from component to redux action creator
- How to test a React component that dispatches a Redux / Thunk action
- Return promise from action in redux
- How to pass argument from component to redux action
- How can I return a React Component from a function and render it onClick?
- Async props pass in React: How to pass a key to update redux store in react? [First from the higher component and then from redux store]
- how does react props merge state passed from parent component and redux store
- How to bind action creator to component in redux thunk
- How to save fetched data from server to component state using redux and redux-thunk?
- How to run a timer in React component for 60 seconds and call a Redux action every 5 seconds
- Typescript - Return the data from Promise Then and do action
- How do I get data from Axios and return it from a Function Component in React?
- Redux Toolkit: createAsyncThunk action dispatched and return rejected promise the action returns empty payload
- How to call from parent component child function in react, typescript and redux
- react redux how to trigger container function with action coming from non react component
- working with setTimeout function that dispatch an action from redux and resolve a promise chain with fetch call
- How to add action from redux connect to component props typescript
More Query from same tag
- Firebase Error: Objects are not valid as a React child (found: object with keys {seconds, nanoseconds})
- React Form with file submission
- Recursively render list of items based on the API response
- Material Ui checkbox controlled state change not working
- Actual filesystem path to sources is visible on browser in deployed app
- react return jsx from function
- React App - button click taking iphone users to top of screen
- Onclick listener - value of string type
- React conditional re-rerender of an array based on filter
- With react-select, select multiple items matching search simultaneously
- Dispatch onBlur before send form
- How to pass state from child to parent with Hooks
- how to Modify a child object from you state in the reducer with Redux
- React animation synchronization
- Fast changing states without Redux
- What is the Alternative for Form Tag in React Fluent-UI?
- Require at least one of two properties to be provided in props
- Dropdown not opening since I changed to component class and removed hooks
- Making a stopwatch counter with user filled data and with PAUSE/RESUME and RESET functionality
- JSDoc: How to set @param for React element as a function param?
- useState in react custom hook always calls the function
- Helper functions to interface
- React Router: props aren't passed down when directly accessing the URL of child component. Will I need to use the same state in both parent and child?
- React Admin: useDataProvider inside a Redux Saga
- How to replace global function while doing unit test with jest
- React this.state.bottles.map is not a function
- how could i return the value inside of a foreach javascript
- url detect regex
- React Hook useEffect has a missing dependency: 'dispatch'. Either include it or remove the dependency array react-hooks/exhaustive-deps
- Can't print String from function (in react tictactoe tutorial)