ptmt / react-native-macos

[deprecated in favor of https://microsoft.github.io/react-native-windows/] React Native for macOS is an experimental fork for writing desktop apps using Cocoa
MIT License
11.24k stars 429 forks source link

Not working with Platform api #123

Closed 7kfpun closed 7 years ago

7kfpun commented 7 years ago

It doesn't work with react-native-router-flux and other packages using Platform api. The error is following:

screen shot 2016-11-06 at 4 23 40 pm
ptmt commented 7 years ago

I suppose that's because they require react-native directly https://github.com/aksonov/react-native-router-flux/blob/b11a84962e4e4d9265770382b8859d21d1a12ea0/src/NavBar.js#L37. Unfortunately, there is no good solution right now for aliasing this, only manually change (fork) the library and abstract react-native. React Native macOS might be updated as a pluggable thing to react-native in the future to support all third-party plugins.

jhen0409 commented 7 years ago

@ptmt, maybe we can write a babel plugin to transform react-native to react-native-macos for import / require? We can add it to transformer by default. Although there may be have a better way.

hmelenok commented 7 years ago

Have the same issue, maybe someone know good router for using with 'react-native-macos'?

ptmt commented 7 years ago

@hmelenok This going to be resolved with https://github.com/ptmt/react-native-macos/pull/125 by @jhen0409 , you can try it right now and provide a feedback.

hmelenok commented 7 years ago

Seems the same now, it not found it in your version of RN

screen shot 2016-11-14 at 23 25 11
hmelenok commented 7 years ago

I had use fork from git+https://github.com/jhen0409/react-native-desktop.git#patch-2 .babelrc:

{
  "presets": [
    "react-native"
  ],
  "plugins": [
    [
      "module-resolver",
      {
        "alias": {
          "react-native": "react-native-macos",
        },
      }
    ],
  ],
}

.flowconfig:

...
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
module.name_mapper='react-native' -> 'react-native-macos'
...

seems as alias working but without Platform

full code there: https://github.com/hmelenok/shelfnativeMacOSX

ptmt commented 7 years ago

Added Platform.select support in 0.11.0-rc4. PR for babel transforming is still under testing

ptmt commented 7 years ago

0.12.0 now have babel-transform plugin