0

本着 7 月 4 日的精神,我想建立一些东西,因此我不会放弃。我一直在努力让它工作一段时间(不仅仅是今天),坦率地说,我厌倦了 react native,而且每次我从 npm 拉包时都会打破这种习惯。

包.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"
  }

应用程序.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 是我想创建的空白 expo 项目,以便在 redux 中使用 ORM

redux orm 错误

在旁注中,我更喜欢解决我的问题而不是专注于这个问题,我不禁想我错过了什么?是的,我对反应和原生反应很陌生,但为什么每个人都喜欢原生反应?我同意在一个项目中使用它,即使我不想这样做,现在我大部分时间都在查看 github 问题以使我的包 json 中的所有内容都能正常工作。每次我去“嘿,这看起来不错,我想使用它”并运行 npm install 时,一切都会中断......所以,老实说,工作的意义何在?我看这一切都错了吗?

4

1 回答 1

1

我尝试了您的存储库并设法使其运行。我做的第一件事就是跑去exp start --ios看看这是否可行。它向我显示了以下错误:

第一次运行时出错

所以我去 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

于 2017-07-05T00:17:08.250 回答