简体   繁体   中英

React Native - react-redux PropTypes error

In my React Native project react: 16.8.3 => 16.8.3 - react-native: ^0.59.5 => 0.59.10

I updated the react-redux for using the hooks from the version 5.xx to 7.1.3 and since the update I'm getting an error with prop-types dependency.

error: bundling failed: Error: Unable to resolve module '../utils/PropTypes' from '/node_modules/react-redux/lib/components/Provider.js': The module '../utils/PropTypes' could not be found from '/node_modules/react-redux/lib/components/Provider.js'.

Indeed, none of these files exist:I already installed the prop-types dependency manually and it does not help me.

It looks like you've already got propTypes there. What you can try, and what worked for me is doing both of the following.

Step 1 : npm ci this will remove node_modules and reinstall with the correct 'acceptable' deps from your packages.json Then you'll need to get clear the React Native packager cache .

Step 2:

RN with Expo

With Expo, this can be done either of two ways:

  1. Run npm start (which is expo start ) and in the same terminal press Shift + r which will reset cache and restart bundler
  2. Use expo start --clear which will clear the expo cache

React Native w/o expo

This should work, the typical watchmen reset:

  • npm start -- --reset-cache
  • or if that doesn't work, try the typical:
    • watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-*
    • (something like this, depends on your machine)

这对我有帮助: npm start -- --reset-cache

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM