Questions tagged [redux-middleware]

88 questions
1
vote
2 answers

How to implement a redux middleware class in TypeScript

According to the typescript definition of Redux, those interfaces should be implemented to make a middelware: /* middleware */ export interface MiddlewareAPI { dispatch: D getState(): S } /** * A…
Nour
  • 5,252
  • 3
  • 41
  • 66
1
vote
1 answer

how to dispatch a action in redux middleware?

I wrote a middleware, like as blow : const testMiddleware = ({ dispatch, getState }) => next => action => { console.log('test middleware') }; export default testMiddleware; and added it to my store: applyMiddleware(testMiddleware) in ever…
Masoud92m
  • 602
  • 1
  • 8
  • 24
1
vote
0 answers

Redux: Middleware to return the actions payload for functional programming

TLDR: Is the following middleware for Redux okay or is it a bad idea / bad practice? If it's bad, how else would you use dispatch with pipe or compose (in a declarative way)? For ES6 version see further down. I initially wanted to open on issue on…
J. Hesters
  • 13,117
  • 31
  • 133
  • 249
1
vote
1 answer

Simple way to access localStorage instead of redux-store

I just exported a few things from my store to the localStorage (actual logged in user) so the user should be able to open a second tab without login again. For putting data in the localStorage i used a Redux-Middleware (if action is login I put the…
1
vote
1 answer

dispatching redux action in middleware cause unexpected behavior

I am trying to understand how redux middleware works, during my experiment I have noticed that dispatching an action from redux middleware may result in an unexpected behavior. I will try to explain the problem by simulating file upload as…
cyrus-d
  • 749
  • 1
  • 12
  • 29
1
vote
1 answer

Why redux-loop actions skip all middlewares?

I run redux-loop official example with a little change: Instead of fetch I use promise with a timeout. I added log middleware (copy-paste from redux.js.org tutorial). side-effect function: import {createStore, compose, applyMiddleware} from…
Stav Alfi
  • 13,139
  • 23
  • 99
  • 171
1
vote
2 answers

TypeError: this.props.loginActionCreater is not a function in react-redux

I am new for react redux here I am trying to call two actions in component. There is login page after click on button I am calling one action that will fetch auth_token then that token I am using in componentWillReceiveProps() for calling another…
Zaif
  • 11
  • 4
1
vote
2 answers

Redux store get empty in component

I have a problem with getting the redux store in my component. I am using redux-react async to fetch data from api. I got the data from jsonplaceholder api, however I have a problem configuring the store and connecting the store with the root…
1
vote
1 answer

How to create a redux store with local data storage?

I am confused by the docs. I am trying to use Redux-storage middleware and this is how they show the store is created with the middleware: const middleware = storage.createMiddleware(engine); const createStoreWithMiddleware =…
ilyo
  • 35,851
  • 46
  • 106
  • 159
0
votes
0 answers

How to retrieve object after post in react redux from api

I created a Todo application in React.js. I have an API to store my todos and their states. In my application I can drag and drop the todos in the state I want and I can also CRUD the states. For the state part I use React-Redux. My problem happens…
0
votes
0 answers

Where from action parameter get in redux middleware?

I am new to react and redux, try to understand in redux middleware, From where the action parameter came? const loggerMiddleware = ({dispatch, getState}) => (next) => (action) => { console.log("Logger Middleware"); if(typeof action !==…
0
votes
1 answer

Why is dispatch returning a promise with no result? (redux middleware)

I came into a React project that uses vanilla Redux with middleware. The way it is setup is as follows: composeEnhancers(applyMiddleware(...middleware.map(f => f(services)))) Now middlware is an array of, well, middleware containing functions.…
0
votes
1 answer

Flutter redux store.dispatch(...) resetting the value of another redux state variable

The scenario is, when the app opens, we need to do two REST API calls, Get User Function List API call Get Chat Bubble List API call We have two redux state variable userFunctionList chatBubbleList state.dart class AppState { final List…
0
votes
0 answers

RTK startListening will accumulate the effects?

For example: export const authMiddleWare = createListenerMiddleware(); const startAuthMiddleWare = authMiddleWare.startListening as TListener; startAuthMiddleWare({ actionCreator: actionSetToken, effect: (_, {dispatch,…
Evgeniy
  • 303
  • 2
  • 9
0
votes
0 answers

Is there any logical mistake in my code ? Middleware not showing decoded data from json file from liveserver?

I have been following Flutter Redux tutorial from youtube. The same is code is working in tutorial but when I implemented it, it's not working logically. Basically, I am fetching data from json file running on live server on my pc and there is no…