I
I
ivanDoligov2020-05-19 10:40:13
React
ivanDoligov, 2020-05-19 10:40:13

How to describe the ref that we get from forwardRef in propTypes?

Good afternoon! Please help, I am getting an error

Warning: forwardRef render functions do not support propTypes or defaultProps. Did you accidentally pass a React component?


if my application uses propTypes, then how can I avoid this warning?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Suntsev, 2020-05-19
@ivanDoligov

It's all in the warning itself
Warning: forwardRef rendering functions do not support propTypes or defaultProps.
Either remove propTypes or don't use refs.

I
ivanDoligov, 2020-05-19
@ivanDoligov

const List = (props, ref) => {
  return (
    <Button
      {...props}
      ref={ref}
    />
  );
}

export default React.memo(React.forwardRef(List));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question