Answer the question
In order to leave comments, you need to log in
How to work with data received asynchronously in React-redux?
There is a server with a .json array of products.
I'm using thunkMiddleware and storing an array in the redux store.
I need to find the most expensive and cheapest product so that the slider element can be passed initial values and max. min. values. But doesn't work.
How to work with api in react-redux?
Here it is described in more detail with code and a picture.
I already wrote here, they promised to help on Skype, but they didn’t help (
But the problem still torments me.
Am I using the wrong approach? I got into a dead end, help
Answer the question
In order to leave comments, you need to log in
Calculate your min/max values in the mapStateToProps function
import React, { Component } from 'react';
import { connect } from "react-redux";
class componentName extends Component {
render() {
const {minValue, maxValue} = this.props
return (
<div>
</div>
);
}
}
const mapStateToProps = (state, ownProps) => {
// здесь у вас есть доступ к redux store с вашим массивом данных
console.log('redux store ', state)
console.log('own component props ', ownProps)
const minVal = ваша функция
const maxVal = ваша функция
return {
minValue: minVal,
minValue: maxVal,
};
};
export default connect(mapStateToProps)(componentName);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question