picker icon indicating copy to clipboard operation
picker copied to clipboard

Picker web import line missing colon causing error

Open je4ngomes opened this issue 6 years ago • 14 comments

https://github.com/react-native-community/react-native-picker/blob/414892c0f633271a59216193d1f439bb6c0a1c96/js/Picker.web.js#L7

https://github.com/react-native-community/react-native-picker/blob/a50ec11d98b7cbb20b13892716ec9601852d9394/js/Picker.web.js#L13

je4ngomes avatar Sep 02 '20 11:09 je4ngomes

Any progress on this issue? Have you worked on a PR? If not, then I can take a look

NateAGeek avatar Dec 18 '20 07:12 NateAGeek

I also encountered this problem when compiling with react native web. any fixes ?

SyntaxError: D:\RahtabMonoRepo\applications\node_modules\@react-native-picker\picker\js\Picker.web.js: Unexpected token (9:12)

7 | 8 | import React from 'react'; > 9 | import type {       |                    ^ 10 | ViewStyleProp, 11 | TextStyleProp, 12 | } from 'react-native/Libraries/StyleSheet/StyleSheet';

mkhib avatar Jan 02 '21 08:01 mkhib

I also encountered this problem when compiling with react native web. any fixes ?

SyntaxError: D:\RahtabMonoRepo\applications\node_modules@react-native-picker\picker\js\Picker.web.js: Unexpected token (9:12)

7 | 8 | import React from 'react';

9 | import type {       |                    ^ 10 | ViewStyleProp, 11 | TextStyleProp, 12 | } from 'react-native/Libraries/StyleSheet/StyleSheet';

@mkhib I have the same issue any solution?

mazor12 avatar Jan 06 '21 17:01 mazor12

I also encountered this problem when compiling with react native web. any fixes ? SyntaxError: D:\RahtabMonoRepo\applications\node_modules@react-native-picker\picker\js\Picker.web.js: Unexpected token (9:12) 7 | 8 | import React from 'react';

9 | import type {       |                    ^ 10 | ViewStyleProp, 11 | TextStyleProp, 12 | } from 'react-native/Libraries/StyleSheet/StyleSheet';

@mkhib I have the same issue any solution?

As a temporary workaround I’ve created two separate components for web and native and used the deprecated picker from ‘react-native’ for the web and it is working as expected.

mkhib avatar Jan 08 '21 07:01 mkhib

I'm not able to reproduce this issue on my side when using it for web. Could you create a minimal sample repo that causes the issue? Thanks

Naturalclar avatar Jan 11 '21 04:01 Naturalclar

error - ./node_modules/@react-native-community/picker/js/Picker.web.js:9:12 Syntax error: Unexpected token

7 | 8 | import React from 'react';

9 | import type { | ^ 10 | ViewStyleProp, 11 | TextStyleProp, 12 | } from 'react-native/Libraries/StyleSheet/StyleSheet';

amitMist avatar Mar 04 '21 00:03 amitMist

any update on this issue?

danilrafiqi avatar Apr 09 '21 06:04 danilrafiqi

any update on this issue?

after tested from latest version, just v1.9.5 work for me

sendyputra avatar Apr 30 '21 14:04 sendyputra

v1.16.5 monorepo web + rn still has error

OkancanCosar avatar Aug 17 '21 11:08 OkancanCosar

I'm also encountering this error when using Picker inside of a typescript project: `

node_modules/@react-native-picker/picker/js/Picker.web.js: Unexpected token (10:12):

at this line:

import type {ViewProps} from 'react-native-web/src/exports/View/types';

using 1.16.5 of the picker

alexandrasmith00 avatar Aug 17 '21 20:08 alexandrasmith00

Hello @Naturalclar, please check minimal repo with repro: https://github.com/Zahoq/rnwPickerIssue (I've created repo with create-react-native-web-app, however I've removed android directory as it was not needed)

Environment: Windows 10, Chrome 93.0.4577.63 (64-bit), React: 17.0.2, @react-native-picker/picker: 2.0.0

to run app:

  1. yarn
  2. yarn web

Compilation attempt results with:

Failed to compile.

./node_modules/@react-native-community/picker/js/Picker.web.js
SyntaxError: C:\code\rnwPickerIssue\node_modules\@react-native-community\picker\js\Picker.web.js: Unexpected token (9:12)

   7 |
   8 | import React from 'react';
>  9 | import type {
     |             ^
  10 |   ViewStyleProp,
  11 |   TextStyleProp,
  12 | } from 'react-native/Libraries/StyleSheet/StyleSheet';

Zahoq avatar Sep 06 '21 19:09 Zahoq

@Zahoq Same issue here, have you found any solution?

d-vincent avatar Sep 10 '21 18:09 d-vincent

:tada: This issue has been resolved in version 2.0.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

Naturalclar avatar Sep 11 '21 11:09 Naturalclar

@d-vincent regarding workaround: you can add webpack configuration to support flow:

  addWebpackModuleRule({
    test: /react-native-(picker|web)(-select)?.*\.jsx?$/,
    use: {
      loader: 'babel-loader',
      options: {
        presets: [
          "@babel/preset-env",
          "@babel/preset-react",
          "@babel/preset-flow",
        ]
      }
    }
  }),

@Naturalclar fix works, thanks!

Zahoq avatar Sep 13 '21 20:09 Zahoq