在 React Native 应用后运行一个独立的 Node.js 进程
在某个目录下开发 Node.js 项目 - 例如 ./background
在您的 React Native JavaScript 源文件中,启动后台进程:
+import RNNode from "react-native-node";
class MyApp extends Component {
// ...
componentDidMount() {
+ RNNode.start();
+ // or specify arguments to the process:
+ RNNode.start(['--color', 'red', '--port', '3000'])
}
componentWillUnmount() {
+ RNNode.stop();
}
// ...
}您可以使用 noderify 等工具来创建一个单个 js 文件,从而减小 rnnodebundle 文件的大小。
暂无开放 Issues,或尚未同步最近议题。