facebook / prop-types

Runtime type checking for React props and similar objects
MIT License
4.48k stars 358 forks source link

Error : `_propTypes2.default.oneOfType is not a function` #385

Closed omardeangelis closed 1 year ago

omardeangelis commented 1 year ago

I get this error when i tried to build my gatsby sites after install react: 18.1.0 Think that the problem is inside react-autosize-input in AutosizeInput.js. link

Do not understand what could be the problem

AutosizeInput.propTypes = {
    className: PropTypes.string, 
    defaultValue: PropTypes.any,
    extraWidth: PropTypes.oneOfType([  
        PropTypes.number,
        PropTypes.string,
    ])
rbuetzer commented 1 year ago

I had the same problem. The problem does not seem to be related to prop-types, so I think this issue can be closed.

Concerning the issue, these are my findings:

The issue seems to be related to tree shaking. If I turn off tree-shaking, oneOfType is found.

Also note that react-autosize-input was removed from react-select several months ago, see https://github.com/JedWatson/react-select/pull/4625. The PR says:

react-autosize-input is a mono-repo that is maintained specifically for react-select. so don't expect the package to be maintained.

I finally solved the issue by upgrading react-select to the newest version and thereby getting rid of react-autosize-input.

ljharb commented 1 year ago

I'd file a bug with your bundler then; tree-shaking isn't supposed to break anything.

I'll close this since it seems decisively related to specific build tools.