React native,redux,redux ORM,expo ...试图让它全部工作。 __fbbatchedbridge

时间:2017-07-04 21:19:57

标签: reactjs react-native redux expo redux-orm

本着7月4日的精神,我想建立一些东西,因此我并没有放弃这一点。我一直试图让它工作一段时间(不仅仅是今天),坦率地说,我厌倦了本地的反应,而且每次从npm拉出一个包时都会有破坏的习惯。

的package.json

"dependencies": {
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-stage-2": "^6.24.1",
    "expo": "^18.0.4",
    "react": "16.0.0-alpha.12",
    "react-native": "https://github.com/expo/react-native/archive/sdk-18.0.1.tar.gz",
    "react-redux": "^5.0.5",
    "redux": "^3.7.1",
    "redux-orm": "^0.9.4",
    "redux-thunk": "^2.2.0"
  },
  "devDependencies": {
    "babel-preset-react-native": "^2.0.0",
    "redux-orm-proptypes": "^0.1.0"
  }

App.js

import React from 'react';
import { Provider } from 'react-redux';  
import store from './store';

export default class App extends React.Component {
  render() {
    return (
      <Provider store={store}>
        <Text>asdasdasD</Text>
      </Provider>
    );
  }
}

存储/ index.js

import { createStore, applyMiddleware } from 'redux';
import thunkMiddleware from 'redux-thunk';
import rootReducer from '../reducers/';

const configureStore = createStore(
  rootReducer,
  applyMiddleware(thunkMiddleware)
);

export default configureStore;

减速器/ index.js

import { combineReducers } from 'redux';
import { createReducer } from 'redux-orm';
import orm from '../models';

const rootReducerCombined = combineReducers({ orm: createReducer(orm) });

export default rootReducerCombined;

模型/ index.js

import { ORM } from 'redux-orm';
import Job from './JobModel';  

const orm = new ORM();
orm.register(Job);

export default orm;

其余的东西非常基本。 Project是我想为using ORM in redux创建的空白展览项目。

redux orm error

另一方面,我更倾向于解决我的问题,而不是专注于此问题,我不禁想到我错过了什么?是的,我是一个非常新的反应和本地反应,但为什么每个人都喜欢本地的反应?我同意在一个项目上使用它,即使我不想,现在我花了大部分时间来查看github问题,让我的包json中的所有东西都能正常工作。每次我去“嘿这看起来很好我想用它”并运行npm安装,一切都坏了......所以,老实说,工作的重点是什么?我看这一切都错了吗?

1 个答案:

答案 0 :(得分:1)

我试用了你的存储库并设法让它运行起来。我做的第一件事就是运行exp start --ios以查看是否可行。它向我显示了以下错误:

error on first run

所以我去了App.js并在第9行看到了Text,但是它没有被导入,所以我从react-native导入了它,并且用一些文本渲染了应用程序。

接下来,我查看了日志并看到了这个警告:

  [exp] jest-haste-map: @providesModule naming collision:
  [exp]   Duplicate module name: babel-preset-react-native
  [exp]   Paths: /Users/brent/coding/reduxormexposf/node_modules/react-native/babel-preset/package.json collides with /Users/brent/coding/reduxormexposf/node_modules/react-native/node_modules/babel-preset-react-native/package.json
  [exp]
  [exp] This warning is caused by a @providesModule declaration with the same name across two different files.

然后检查了package.json,发现有一堆babel模块,但是babelrc实际上并没有使用任何一个 - 它只使用了babel-preset-expo。所以我删除了所有这些插件,关闭了打包器,再次运行exp start --ios,警告就消失了。

我不确定你是如何在你的帖子中出现__fbBatchedBridge is undefined错误的状态,有很多方法可以发生。错误消息根本不具有描述性,应该进行改进。包装器很可能没有运行(exp start)。如果问题仍然存在,请告诉我,但其他问题应该得到解决。我提交了一个拉取请求,其中包含我所讨论的更改:https://github.com/ODelibalta/reduxormexposf/pull/1