Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  7] [ 5]  / answers: 1 / hits: 30518  / 8 Years ago, wed, february 17, 2016, 12:00:00

I'm dispatching an action from some-other component , and store is getting updated with svgArr property, but though the following Stateless component connect'ed to the store , it ain't getting updated when store changes for svgArr.


Is it how it suppose to behave as it's a stateless component ? Or am I doing something wrong ?


const Layer = (props) => {
console.log(props.svgArr);
return (<div style = {
{
width: props.canvasWidth,
height: props.canvasWidth
}
}
className = {
styles.imgLayer
} > hi < /div>);
};

connect((state) => {
return {
svgArr: state.svgArr
};
}, Layer);

export default Layer;

More From » reactjs

 Answers
1

Here's a rewrite of your code



import {connect} from 'react-redux';

// this should probably not be a free variable
const styles = {imgLayer: '???'};

const _Layer = ({canvasWidth}) => (
<div className={styles.imgLayer}
style={{
width: canvasWidth,
height: canvasWidth
}}
children=hi />
);

const Layer = connect(
state => ({
svgArr: state.svgArr
})
)(_Layer);

export default Layer;

[#63289] Sunday, February 14, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sonja

Total Points: 541
Total Questions: 113
Total Answers: 114

Location: Anguilla
Member since Sun, Jan 29, 2023
1 Year ago
;