how to change my functional
component to class
component my code is below
const SortableList = SortableContainer(
({ items, SpeedGraph, StepLengthGraph, CadenceGraph, PaceGraph, graphPopupHandler}) => (
<div>
{items.map((value, index) => (
<SortableItem
key={`item-${index}`}
SpeedGraph={SpeedGraph}
StepLengthGraph={StepLengthGraph}
CadenceGraph={CadenceGraph}
PaceGraph={PaceGraph}
graphPopupHandler={graphPopupHandler}
index={index}
value={value}
/>
))}
</div>
)
);
i try to change this code but not working for me.
In class components you need to implement render
function and return your jsx from this function and access props using this.props
While in functional components you just return jsx directly from function and access props using first argument in that function
class SortableList extends React.Component {
render(){
const { items, SpeedGraph, StepLengthGraph, CadenceGraph, PaceGraph, graphPopupHandler} = this.props;
return(
<div>
{items.map((value, index) => (
<SortableItem
key={`item-${index}`}
SpeedGraph={SpeedGraph}
StepLengthGraph={StepLengthGraph}
CadenceGraph={CadenceGraph}
PaceGraph={PaceGraph}
graphPopupHandler={graphPopupHandler}
index={index}
value={value}
/>
))}
</div>
)
}
}