Questions tagged [mapstatetoprops]
58 questions
0
votes
2 answers
React native app performance on connect(mapStateToProps, mapDispatchToProps)
I'm creating react native app with redux state management. I want to know what is the best practice of having connect(mapStateToProps, mapDispatchToProps).
I have several component classes i.e. ParentA, ChildA, ChildB. Currently I'm getting state…

John Stuart
- 950
- 5
- 11
- 28
0
votes
1 answer
how to get redux state in setInterval
I use Redux and react, and in timer after one second get value of redux state. Each time the Timer is executed, the value of the state does not change and it is the initial value .initial value in state is
00:00:00
note: The value in the state is…

zahraei
- 79
- 1
- 9
0
votes
0 answers
How to map props in MapStateToProps?
I have tsx file who is returning this:
return (
<>
data.map((item, i) => {
let fullNameLetters = item.fullName.substring(0, 2);
if (item.fullName.indexOf(' ') > 0) {
fullNameLetters =…

Kate
- 288
- 2
- 4
- 17
0
votes
1 answer
What state data do I need to pass to mapStateToProps
I am trying to put in a form component in my app using Redux for the first time and I am trying to get my head around what I have to create Reducers / Actions for.
In other components I have my user and messages passed into mapStateToProps and they…

James Gee
- 129
- 1
- 3
- 24
0
votes
1 answer
react-redux current props value
I've three buttons on the page, and when clicking on any button i want to get that selected value from the store filtered by id(done in reducer). I'm trying to use redux with mapStateToProps and mapDispatchToProps pattern, but looks like when i try…

user212223
- 1
- 1
- 3
0
votes
0 answers
why is mapStateToProps returning the default/initial/empty data, when I've dispatch an action
I've had this bug for days now, when I dispatch an action, store.getState() shows the updated state,
but when using mapStateToProps in other component, the updated state is lost, and what is shown is the default state.
On Form Submission
const…

Osaze Agbi
- 3
- 4
0
votes
2 answers
Map function not rendering data in List item despite having data
I am receiving the list of tools data through mapStateToProp. I also looked after other similar issues which addressed issue via only one solution of adding return within map function, but still it doesn't work. Checked in logs the data is present…

Suraj Sawant
- 21
- 4
0
votes
0 answers
Testing mapStateProps function using jest
Can someone please help me to write a jest test case for mapStateProps.
I have read all the question everywhere but I was not able to releate to this.
Component code
function mapStateToProps({ leftRecords}) {
return {…

groot
- 57
- 3
- 12
0
votes
0 answers
Accessing the Object received from Django Rest API and passed to props creates a TypeError in the render() method of React
Description: After registering with token authentication at the DRF I receive the token and a json user object into my authReducer, which is passed further down into my rootReducer, and stored as auth.userin my state.
The user object is:
{id:1,…

Ernst Plesiutschnig
- 183
- 2
- 10
0
votes
1 answer
React Component doesn't read state from reducer with 'mapStateToProps'
I am using reducer to read states and see if the user is authenticated. I can read the states from other files but only one particular file cannot read states.
below, I define mapStateToProps
const mapStateToProps = state => ({
user:…

coderxx
- 11
- 2
0
votes
1 answer
React Hook useEffect() - Run after mapStateToProps
I am using hooks in my React application to handle state.
My application has notes that are associated to categories by categoryId.
Notes in a specific category are shown by mounting a NoteList component.
The…

Kermit
- 2,865
- 3
- 30
- 53
0
votes
2 answers
how to assign a dynamic parameter in an array in the computed method and mapState
hello here is my computed method :
computed:
mapState({
aftermovie: (state) => state.festival.aftermovies[id]
}),
id: {
set() { return this.$route.params.id}
},
if i put state.festival.aftermovies [0] it works but if i…

vinc lre
- 15
- 4
0
votes
1 answer
MapStateToProps not being called after changing STATE in reducer
I have theses files :
numPadHandler (my reducer),
configureStore (my store),
TestRedux (my component, trying to use the store)
and my app file.
reducer :
// store/reducers/numpadReducers/numpadHandler
const initialState = { valueNumPad:…

JamesStandbridge
- 41
- 5
0
votes
2 answers
Losing props state data when reloading the page
Here is the code:
const mapStateToProps = (state, ownProps) => {
const id = ownProps.match.params.id;
const sheets = state.firestore.data.sheets;
const sheet = sheets && sheets[id];
const rows = sheet.rows;
return {
rows: rows,
…

Ganesh Srambikal
- 1
- 2
0
votes
11 answers
React & Redux: State of component is not updating even with mapStateToProps
I posted an answer below, but if someone can explain why this is necessary you'll get the bounty, I went through a redux tutorial and feel like I didn't learn about mapDispatchToProps, only mapStateToProps. If you can explain at a deeper level what…

Sam
- 1,765
- 11
- 82
- 176