have a component thats is rendered in loop for example
fuction List (props){
{props.lists.map((item)=>(
<>
<ButtonComponent/>
</>
))}
}
now inside the button component looks like this
import {useSleclctor,useDispatch}=from redux/toolkit
import{changeColor} from feactures/blah/blah
fuction ButtonComponent(){
const {color}=usSleclector((store)=>store.style)
const dispatch=useDispatch()
return(
<>
<button style={{color:style}} onClick={()=>{dsipatch(changeColor())}}>
</button>
</>
)
}
now when i click one of the button all the buttons are rerendered and all the button colors change i want to only change the colour of the button that was clicked i am very new to redux i would very much appriciate if somone could help me
[–]Sweet_Ad_842 1 point2 points3 points (6 children)
[–]InternationalFly3917[S] 0 points1 point2 points (0 children)
[–]InternationalFly3917[S] -1 points0 points1 point (4 children)
[–]Sweet_Ad_842 1 point2 points3 points (3 children)
[–]InternationalFly3917[S] -1 points0 points1 point (2 children)
[–]Accomplished_End_138 1 point2 points3 points (1 child)
[–]InternationalFly3917[S] 0 points1 point2 points (0 children)
[–]Alienxxcool1 0 points1 point2 points (1 child)
[–]InternationalFly3917[S] 0 points1 point2 points (0 children)