score:12

Accepted answer

It's because you have eslint config which requries you to add displayName and propTypes

Do something like

const Child: React.FC<Data> = React.memo(({ time }) => {
  console.log('child render...');
  const newTime: string = useMemo(() => {
    return changeTime(time);
  }, [time]);

  return (
    <>
      <p>Time is {newTime}</p>
      {/* <p>Random is: {children}</p> */}
    </>
  );
});

Child.propTypes = {
  time: PropTypes.isRequired
}

Child.displayName = 'Child';

score:2

If you are working with React and TypeScript, you can turn off the react/prop-types rule.

This is because TypeScript interfaces/props are good enough to replace React's prop types.


Related Query

More Query from same tag