why is componentdidupate better than getderivedstatefromprops
Performances reason: it avoids unnecessary re-render. As getDerivedStateFromProps is called before rendering on init, you can initialise your state in this function instead of having a constructor to do so. Currently you had to have a constructor or componentWillMount to init your state before initial rendering.