Questions tagged [react-redux]

The react-redux package provides the official React bindings for Redux: the `useSelector` and `useDispatch` hooks and the `connect` higher-order component. Use this tag for questions about accessing and updating Redux state in React components.

React Redux is a library that contains React bindings for Redux. Redux defines itself as a predictable state container for JavaScript apps. Redux works especially well with React.


Resources


Related tags

Redux enhancers:

Alternatives to Redux:

23349 questions
4
votes
0 answers

Access to redux state during Selenium testing

Recipee sharing here, For my app, wanted to automate user PoV testing with Selenium and told myself that being able to read the state and send redux actions through Selenium would be great. Selenium is driven from NodeJs. In node JS to send a…
Franck
  • 257
  • 2
  • 10
4
votes
3 answers

How to send props in class component to functional component?

I am beginner to reactjs. need to know how to send the props values in one page to another page. Props are on the first page I can get the class component value how to get the values in another page. Thanks in advance wallcolor.jsx import React, {…
Manohar tk
  • 286
  • 2
  • 9
4
votes
0 answers

JSLint: Disallow state. in Redux connect functon

Need to write a (custom) ESLint rule for this: Good: connect((state, props) => { return { organizations: Organization.getActive(state, props.user), ... : Model.scope(state, prop...), }; })(MyComponent); Bad: All the stuff…
hakunin
  • 4,041
  • 6
  • 40
  • 57
4
votes
3 answers

How to cleanup useEffect correctly when using history.push?

I am using react-redux and redirecting users based on the value of prop. How can I handle the error produced in the console? I have used useEffect to push users to different components based on props. I'm not sure if this is the correct way to do…
Freddy.
  • 1,593
  • 2
  • 20
  • 32
4
votes
0 answers

How to make react-router-dom return number instead of string in matched parameters

I'm using parameters in my routes with react-router-dom and doing a regex check to make sure the parameters match the expected type. For example: This makes sure that the objectId is…
shadyhill
  • 525
  • 5
  • 15
4
votes
2 answers

React-leaflet: how to update marker positions?

I can't understand how to update my markers correctly using react-leaflet. Using this example: import React from 'react'; import { render } from 'react-dom'; import { connect } from 'react-redux'; import { Map, Marker, TileLayer } from…
Pedro Brost
  • 1,402
  • 1
  • 14
  • 25
4
votes
1 answer

can not put file in redux array

I am uploading file in redux array and it seems it is getting file as payload since it logs in console but when i push it in array it puts empty object instead of actual file, i haven't faced this problem so i do not know what to do so here is…
iLiA
  • 3,053
  • 4
  • 23
  • 45
4
votes
1 answer

How to use axios to get api items in redux?

I am learning Redux so this may be a basic question and answer but here we go. I am trying to fetch a list of items from my backend api (/api/items) and pass them into my ShoppingList.js component so that when the component loads the list of items…
Brock
  • 125
  • 13
4
votes
2 answers

When using useDispatch() inside useEffect(), action doesn't appear to be called immediately

I want to dispatch an action when a page is first mounted. This action set loading to be true immediately, then set it to false after 2 seconds. Noticing that it has different behaviours when I use hooks/react component. When I write it in a react…
Aonan Li
  • 143
  • 1
  • 8
4
votes
1 answer

Using redux, how to avoid rendering old state data before making a new API call?

I've just started to do some experiments with redux and react-redux. Note: I'm using Hooks, so I'm using useSelector() and useDispatch() custom hooks from react-redux. Imagine I have some piece of state to get a blogPost from DB based on a slug. My…
cbdeveloper
  • 27,898
  • 37
  • 155
  • 336
4
votes
2 answers

Can we add events on react fragment?

In my case, I have to wrap up the content in the parent component without adding extra div element to the DOM. So, I wrapped the element with the react fragment. I got a use case to add the native browser event to the react fragment, Is that even…
jai sai Kiran
  • 41
  • 1
  • 5
4
votes
1 answer

How to Pass an ID to API call using redux saga?

As I am new to React and Redux-Saga, I was facing a problem with passing ID from listing page to detail page onClick of button. Here, I wanted to dispatch the ID and pass it to the Api-saga and fetch the data of that ID. Just help me to pass the…
Akhil
  • 43
  • 1
  • 5
4
votes
0 answers

Sharing a Class Instance Object Between React Components

If I have, say, a network manager class that I have implemented with a singleton pattern. export default class Manager { private static _Instance: Manager; public static get Instance(): Manager { if (Manager._Instance) { return…
afryingpan
  • 343
  • 6
  • 15
4
votes
2 answers

Testing a custom hook with renderHook

I want to test a custom hook which was implemented as an helping function for code reuse with other hooks. It's calling useDispatch and useSelector in its implementation, along with saving data in the session storage: export function…
CodeMonkey
  • 11,196
  • 30
  • 112
  • 203
4
votes
0 answers

Is there a way to access phone gallery in reactjs application?

Hi I am developing a ReactJS application which eventually I will have to convert into PWA application. My confusion is whether we have any reactJS plugins which can help me solve this problem. For the web, it is easy using file dialogs, selectors,…
Anupam Hore
  • 373
  • 1
  • 3
  • 5
1 2 3
99
100