Mar*_*nez 3 react-native redux redux-thunk react-native-router-flux react-navigation
我使用这个主要依赖项工作在本机应用程序上:
我正在使用这个package.json:
"dependencies": {
"expo": "23.0.4",
"humps": "^2.0.0",
"install": "^0.10.1",
"lodash": "^4.17.4",
"native-base": "^2.3.5",
"react": "16.0.0",
"react-native": "0.50.4",
"react-native-extend-indicator": "^0.1.2",
"react-native-keyboard-aware-scroll-view": "^0.4.2",
"react-native-maps": "^0.19.0",
"react-native-maps-directions": "^1.3.0",
"react-native-modal-datetime-picker": "^4.13.0",
"react-native-qrcode": "^0.2.6",
"react-native-router-flux": "4.0.0-beta.24",
"react-native-svg-uri": "^1.2.3",
"react-native-swiper": "^1.5.13",
"react-native-vector-icons": "^4.4.2",
"react-navigation-redux-debouncer": "^0.0.2",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.2.0",
"swagger-client": "2.1.32"
}
Run Code Online (Sandbox Code Playgroud)
应用程序正在使用expo所以我使用以下命令安装依赖项:
然后运行应用程序
我工作正常,因为我想添加一个新的依赖项,所以我删除了node_modules文件夹和yarn.lock文件,添加了新的依赖项并再次执行yarn安装.
之后,我在打开应用程序时遇到此错误:
TypeError:undefined不是函数(评估'addListener')
它与react-navigation有关,但我使用的是react-native-router-flux 4.0.0-beta.24,它在内部使用react-navigation ^ 1.0.0-beta.19.
我最近注意到使用react-navigation的人对此有一些麻烦(https://github.com/react-navigation/react-navigation/issues/3416)但使用beta.28版本.
如果我回到之前的node_modules文件夹(从垃圾箱)我的应用程序运行良好,所以..可能是因为我的package.json 的^符号的某些依赖性不再兼容..也许thunk或反应本机路由器与我的反应本机版本的通量.
有任何想法吗?
当我使用react thunk中间件时,这是代码的一部分:
import {applyMiddleware, compose, createStore} from 'redux';
import thunkMiddleware from 'redux-thunk';
import {createLogger} from 'redux-logger';
import getRootReducer from "../reducers/index";
import navigationDebouncer from 'react-navigation-redux-debouncer';
import {restApi} from "../lib/restApi";
const loggerMiddleware = createLogger({ predicate: (getState, action) => __DEV__ });
export default function getStore(initialState) {
const enhancer = compose(
applyMiddleware(
thunkMiddleware.withExtraArgument(restApi),
navigationDebouncer(600),
loggerMiddleware
),
);
return createStore(
getRootReducer,
initialState,
enhancer
);
}
Run Code Online (Sandbox Code Playgroud)
这是主要的应用程序:
import React, {Component} from 'react';
import {Provider} from 'react-redux'
import getStore from './src/store/configureStore'
import {StatusBar} from 'react-native'
import AppNavigation from './src/navigation';
const Store = getStore();
export default class App extends Component {
constructor(props) {
super(props);
}
async componentWillMount() {
await Expo.Font.loadAsync({
'Ionicons': require('native-base/Fonts/Ionicons.ttf'),
});
}
render() {
StatusBar.setHidden(true);
return (
<Provider store={Store}>
<AppNavigation/>
</Provider>
);
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:我发现现在react-native-router-flux使用1.0.0 react-navigation(新的稳定版本),并且在使用1.0.0-beta.27版本之后...应用程序与beta一起工作版本,但1.0.0版本有这个问题... 所以我认为你在上一个版本中使用固定版本的反应导航(1.0.0-22.beta)
所以问题是,有没有办法仍然使用RNRF 4.0.0-beta.24 BUT使用固定版本(例如1.0.0-27.beta)?
我的意思是,我认为4.0.0-beta.24使用^ 1.0.0-beta19(这将导致安装最后的1.0.0版本)和更新版本如4.0.0-beta .28使用固定的较低版本(1.0.0-beta.22)
所以经过一些研究和一些测试,我想回答我的问题.
问题在于反应导航依赖关系处理内部react-native-router-flux
依赖关系是:
react-native-router-flux beta.0 - beta.24 -> react-navigation ^1.0.0-beta.19
react-native-router-flux beta.25 - beta.28 -> react-navigation 1.0.0-beta.22
Run Code Online (Sandbox Code Playgroud)
这里最大的区别是从0到beta24的版本使用^
那么..那有什么问题?
在安装依赖项时,beta24将搜索自1.0.0-beta.19以来最新版本的react-navigation,该版本是最新的1.0版本的react-navigation(该库不再是测试版).
react-native-router-flux不提供对该依赖的支持.它既没有提供对其他olders依赖项的支持,所以他们只是将1.0.0-beta22 反应导航依赖项固定在他们最新的发行版package.json上(从beta 26开始).
可能他们会修复它,因为有很多应用程序使用redux或其他库与react-native-router-flux没有良好的交互.
所以现在.. Redux用户的解决方案是使用beta26版本,对于那些不使用redux的人来说可能是beta27和beta28就可以了.
以下是讨论:https://github.com/aksonov/react-native-router-flux/issues/2865
这是另一个相关问题:https://github.com/aksonov/react-native-router-flux/issues/2799
归档时间: |
|
查看次数: |
3528 次 |
最近记录: |