question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed to compile when using react-native-elements in create-react-native-web-app project

See original GitHub issue

I’ve been redirected from here.

Explain what you did Trying to create a react-native web project, following this tutorial

The bug When adding react-native-elements and react-native-vector-icons, and editing the webpack as described in the walkthrough, I receive

Failed to compile.

./node_modules/react-native-ratings/src/SwipeRating.js
SyntaxError: /Users/arthur/workspace/ReactNativeWorkspace/sfcc/web-sandbox-test/node_modules/react-native-ratings/src/SwipeRating.js: Support for the experimental syntax 'classProperties' isn't currently enabled (41:23):

  39 | 
  40 | export default class SwipeRating extends Component {
> 41 |   static defaultProps = {
     |                       ^
  42 |     type: 'star',
  43 |     ratingImage: require('./images/star.png'),
  44 |     ratingColor: '#f1c40f',

Add @babel/plugin-proposal-class-properties (https://git.io/vb4SL) to the 'plugins' section of your Babel config to enable transformation.

when running yarn web

To Reproduce To reproduce you can simply follow along the instructions in the walkthrough, and when you replace <TouchableHighlight> with <Button> you should receive the same error

Environment

software version
react-native-vector-icons ^6.2.0
react-native-elements ^1.0.0
react-native 0.55.x
npm 6.5.0
yarn 1.13.0
OS macOS High Sierra 10.13.4

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
haruelrovixcommented, Mar 16, 2019

@arthurpankiewicz @thorakmedichi as suggested by @iRoachie , if you guys following this tutorial, you just need to add react-native-ratings and react-native-status-bar-height to webpack config.

  // Process JS with Babel.
  {
    test: /\.(js|jsx|mjs)$/,
    include: [
      paths.appSrc,
      `${paths.appNodeModules}/react-native-elements`,
      `${paths.appNodeModules}/react-native-ratings`,
      `${paths.appNodeModules}/react-native-status-bar-height`,
      `${paths.appNodeModules}/react-native-vector-icons`
    ],
    loader: require.resolve('babel-loader')

RNE version:

    "react-native-elements": "^1.1.0",
    "react-native-vector-icons": "^6.1.0",

Result:

See this PR for more details, #1.

2reactions
iRoachiecommented, Feb 18, 2019

Hey @arthurpankiewicz you may have to add react-native-ratings to you webpack config as well https://gist.github.com/haruelrovix/01d335dfcabec17a6aa5bc7a53fef277. Let me know if that works

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error while adding react native elements to react native
Since "native" packages don't include compiled code (es5 after babel and jsx transformation), to use them in web you must add the libraries ......
Read more >
React Native Web
Comprehensive Guide to create simple app using React Native Web and React Native Elements.
Read more >
Comprehensive Guide to Creating Simple Apps using React ...
Have you ever wondered, is it possible to create an (Android | iOS | Website) app using single codebase? The answer: Yes, it...
Read more >
Blog | React Native Elements
ToC#. Initialize the project using CRNWA; Make sure everything works: Android, iOS and Web; Add RNE latest ( 1.0.0-beta7 ) to the project;...
Read more >
react-native-elements - npm
React Native Elements & UI Toolkit. Latest version: 3.4.3, last published: 2 days ago. Start using react-native-elements in your project by ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found