problem:
Warning: forwardRef render functions do not support propTypes or defaultProps. Did you accidentally pass a React component?
analysis
Reason: forwardRef will invalidate the defaultProps and propTypes properties of the stateless component.
import React, {
forwardRef} from 'react';
function A(props, ref) {
return null;
}
A.defaultPorps = {
}
export default forwardRef(A);
solve:
import React, {
forwardRef} from 'react';
const A = forwardRef((props, ref) => {
return null;
})
A.displayName = 'A';
A.defaultPorps = {
}
export default A;
issues
https://github.com/facebook/react/issues/16653
https://stackoverflow.com/questions/59716140/using-forwardref-with-proptypes-and-eslint