React-native-snap-carousel: Attempted import error: 'ViewPropTypes'

Created on 14 Oct 2020  路  5Comments  路  Source: meliorence/react-native-snap-carousel

C:/Projects/ReactNative/pwaExpo/node_modules/react-native-snap-carousel/src/pagination/PaginationDot.js
Attempted import error: 'ViewPropTypes' is not exported from 'react-native-web/dist/index'.
  • "expo": "~39.0.2"

  • "react-native": "https://github.com/expo/react-native/archive/sdk-39.0.3.tar.gz",

  • "react-native-web": "~0.14.0",

    "devDependencies": { "@babel/core": "~7.11.6", "@babel/plugin-transform-react-jsx-source": "^7.10.5", "@expo/webpack-config": "^0.12.38", "babel-plugin-import": "^1.13.1", "babel-plugin-root-import": "^6.5.0" },

Most helpful comment

For those who want to automate this fix until this issue is resolved - here is a combined version of this and this workarounds in one .sh-script:

# Fix react-native-web compile issue. See:
# https://github.com/necolas/react-native-web/issues/1537
# https://github.com/archriss/react-native-snap-carousel/issues/770

echo 'Fixing PropTypes issues'

if test -f node_modules/react-native-web/dist/exports/ViewPropTypes/index.js; then
   echo "ViewPropTypes problem fixed already!"
else
    mkdir node_modules/react-native-web/dist/exports/ViewPropTypes
    touch node_modules/react-native-web/dist/exports/ViewPropTypes/index.js
    echo 'var ViewPropTypes = { style: null }; export default ViewPropTypes;'>> node_modules/react-native-web/dist/exports/ViewPropTypes/index.js
    echo "export { default as ViewPropTypes } from './exports/ViewPropTypes';">> node_modules/react-native-web/dist/index.js
fi

Put this into .sh-file somewhere in your project and then add the following command to postinstall in package.json:

"postinstall": "chmod 777 web-postinstall-fix.sh && ./web-postinstall-fix.sh"

Then the necessary fix will be applied after each dependencies install.

Regards,
Ilya

All 5 comments

C:/Projects/ReactNative/pwaExpo/node_modules/react-native-snap-carousel/src/pagination/PaginationDot.js
Attempted import error: 'ViewPropTypes' is not exported from 'react-native-web/dist/index'.
  • "expo": "~39.0.2"
  • "react-native": "https://github.com/expo/react-native/archive/sdk-39.0.3.tar.gz",
  • "react-native-web": "~0.14.0",
    "@babel/core": "~7.11.6", "@babel/plugin-transform-react-jsx-source": "^7.10.5", "@expo/webpack-config": "^0.12.38", "babel-plugin-import": "^1.13.1", "babel-plugin-root-import": "^6.5.0" },
    ```

same here after upgrading from expo 38.0 to 39.0

I have the same problem. Anyone has a fix for this?
I'm also getting this error:
image

Guess it's related to this issue:
https://github.com/necolas/react-native-web/issues/1537

Also getting this with basically any image carousel library I tried to use. Commenting to bring more attention to the topic. Surprised that not more people are talking about it.

I managed to get it working with this work around

For those who want to automate this fix until this issue is resolved - here is a combined version of this and this workarounds in one .sh-script:

# Fix react-native-web compile issue. See:
# https://github.com/necolas/react-native-web/issues/1537
# https://github.com/archriss/react-native-snap-carousel/issues/770

echo 'Fixing PropTypes issues'

if test -f node_modules/react-native-web/dist/exports/ViewPropTypes/index.js; then
   echo "ViewPropTypes problem fixed already!"
else
    mkdir node_modules/react-native-web/dist/exports/ViewPropTypes
    touch node_modules/react-native-web/dist/exports/ViewPropTypes/index.js
    echo 'var ViewPropTypes = { style: null }; export default ViewPropTypes;'>> node_modules/react-native-web/dist/exports/ViewPropTypes/index.js
    echo "export { default as ViewPropTypes } from './exports/ViewPropTypes';">> node_modules/react-native-web/dist/index.js
fi

Put this into .sh-file somewhere in your project and then add the following command to postinstall in package.json:

"postinstall": "chmod 777 web-postinstall-fix.sh && ./web-postinstall-fix.sh"

Then the necessary fix will be applied after each dependencies install.

Regards,
Ilya

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AndrePech picture AndrePech  路  4Comments

wkwyatt picture wkwyatt  路  4Comments

codejet picture codejet  路  5Comments

ajonno picture ajonno  路  4Comments

siderakis picture siderakis  路  3Comments