I have a problem with the slice() function.
My code:
constructor(props){
super(props);
this.state({
data: props.data
})
}
//my function
onSliceData = () => {
let data = this.state.data;
let sliceData = data.slice(0,5);
return sliceData;
}
My problem is my function does not return anything. When I console.log(data) in onSliceData I receive result like this:
And when I console.log(sliceData) I just receive []
I try using Object.keys to convert data to array but maybe not working.
I need some help.
sliceitself.