はじめに:私はJavascript、Babel、React-Nativeを初めて使用しています。ネイティブとリレーの互換性、互換性。一緒に働くための公式な方法?
私は、中継元のTodoMVCの例を使って自分のアプリケーションを開発しています。 React-Native + Relayを簡単に連携させることが可能かどうか疑問に思っていましたか?
私のbabelRelayPluginをセットアップし、それを私の.babelrcに追加しました。 "^ 0.7.3"と "babel-relay-plugin": "^ 0.7.3"のnpmパッケージをインストールしましたが、 "npm install"と "react-native start"を実行した後、 「認識できないモジュール 'react-relay'」または「relay is not defined」というエラーが表示されます。
このスレッドを読んで、最後のコメント(https://github.com/facebook/relay/issues/26#issuecomment-194570137)を見ると、私は新しいReact-Native + RelayプロジェクトのためのTodoMVCだけを使うべきだと思います。
これは間違いありませんか?
はここに私の.babelrc
{
"env": {
"development": {
"passPerPreset": true,
"presets": [
{
"plugins": [
"./plugins/babelRelayPlugin"
]
},
"react-native"
]
},
"server": {
"plugins": [
"./plugins/babelRelayPlugin"
],
"presets": [
"es2015",
"stage-0"
]
}
}
}
であることはここで
{
"name": "testApp",
"version": "1.0.0",
"private": true,
"scripts": {
"clean:babelrc": "find ./node_modules -name react-packager -prune -o -name '.babelrc' -print | xargs rm -f",
"postinstall": "npm run clean:babelrc",
"start": "BABEL_ENV=server babel-node ./server.js",
"update-schema": "babel-node ./scripts/updateSchema.js"
},
"dependencies": {
"babel-preset-es2015": "^6.5.0",
"babel-preset-react-native": "^1.5.1",
"babel-preset-stage-0": "^6.5.0",
"babel-relay-plugin": "^0.7.3",
"express": "4.13.4",
"express-graphql": "0.4.9",
"graphql": "0.4.17",
"graphql-relay": "0.3.6",
"moment": "^2.12.0",
"node-fetch": "^1.4.1",
"react": "^0.14.5",
"react-native": "^0.22.2",
"react-native-animatable": "^0.5.2",
"react-native-aws3": "0.0.1",
"react-native-camera": "git+https://github.com/lwansbrough/react-native-camera.git",
"react-native-console-panel": "0.0.7",
"react-native-contacts": "^0.2.3",
"react-native-keyboard-aware-scroll-view": "0.0.6",
"react-relay": "^0.7.3",
"sync-request": "^3.0.0",
"uuid-v4": "^0.1.0"
},
"devDependencies": {
"babel-cli": "^6.6.4",
"flow-bin": "^0.22.1"
},
"engines": {
"npm": ">=3"
}
}
最新のReact Native(0.22)およびRelay(0.7.3)リリースでは、それらをすぐに一緒に使用することが可能になりました。 .babelrcとpackage.jsonを共有することはできますか?また、反応リレーをインポートする場所。 – freiksenet
ここにReact NativeとRelayで構築したプロジェクトの例があります。これは参考になります。 https://github.com/reindexio/reindex-examples/tree/master/react-native-gallery – freiksenet
@freiksenetがbabelrcとpackage.jsonで私の投稿を更新しました。あなたのパッケージを提供していただきありがとうございます。私はあなたの設定を見ていきます。 –