Answer the question
In order to leave comments, you need to log in
Is it possible to get array element from redux state using mapStateToProps?
You need to get one of the elements of the state stored in redux by the router parameter. Currently wrote the following:
class CoinDetails extends React.Component {
getCoinsDetails = () => {
const coinSymbol = this.props.match.params.id;
return this.props.coins.data.find(item => item.symbol === coinSymbol);
}
render(){
const coin = this.getCoinsDetails();
return (
<div>
{coin.name}
</div>
)
}
}
const mapStateToProps = store => {
return {
coins: store.coins,
}
}
export default connect(mapStateToProps)(CoinDetails);
Answer the question
In order to leave comments, you need to log in
The answer is simple, you don't need to do anything with the picture, just rotate the block with the text
-webkit-transform: rotate(-45deg); //Chrome, Safari
-moz-transform: rotate(-45deg); //Firefox
-o-transform: rotate(-45deg); //Opera
-ms-transform: rotate(-45deg); //IE
transform: rotate(-45deg); //browsers without prefixes Adjust the
angle yourself.
I think something like this , if necessary with support for IE8
const coinSelector = (state, ownProps) =>
state.coins.data.find(coin => coin.symbol === ownProps.match.params.id);
const mapStateToProps = (state, ownProps) => ({
coin: coinSelector(state, ownProps),
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question