I have found no answer, which brought a solution. The error is thrown in the const sorted of my child component. I tried to give the destructured array "videos" into an extra const, but that not works. Thanks for your help
Here is the snippet from my child-component:
const VideoSlider = ({state}) => {
const sorted = state.sort((a,b)=>(a.clicked < b.clicked) ? 1 : -1);
const [slideIndex, setSlideIndex] = useState(0);
const handleClick = (direction)=>{
if(direction === "left"){
setSlideIndex(slideIndex > 0 ? slideIndex-1 : 0);
}
else{
setSlideIndex(slideIndex < sorted.length - 4 ? slideIndex + 1 : sorted.length - 4);
}
}
Here is the snippet from my parent component:
const MostSeen = () => {
const {videos} = useSelector((state)=>state.videos);
const dispatch = useDispatch();
useEffect(()=>{
dispatch(getAllVideos());
}, [dispatch]);
const stateVideos = videos;
return (
<Container>
<TitleHolder>
<Title>Most viewed videos</Title>
</TitleHolder>
<ContentHolder>
<VideoSlider state={stateVideos}/>
</ContentHolder>
</Container>
)
}