更新到SDK 33后可能出现导入错误

时间:2019-08-04 00:32:21

标签: react-native expo

我已经从SDK 32升级到expo SDK 33,并且遇到以下错误:

  

警告:React.createElement:类型无效-预期为字符串   (对于内置组件)或类/函数(对于复合   组件),但得到:%s。%s%s,未定义,您可能忘记了导出   您的组件来自定义它的文件,或者您可能已经混合了   设置默认名称并命名导入。

     

在App.js:117上检查代码,

我的App.js看起来像这样(简化)

import React, { Component } from 'react';
import { Alert, SafeAreaView } from 'react-native';
import { Root } from "native-base";
import {
    StackNavigator,
    addNavigationHelpers,
} from 'react-navigation';
import {
    createStore,
    applyMiddleware,
    combineReducers,
    compose
} from 'redux';
import {
    createReduxBoundAddListener,
    createReactNavigationReduxMiddleware,
} from 'react-navigation-redux-helpers';
import { Provider, connect } from 'react-redux';
import thunk from "redux-thunk";

import {
    moveTo,
    moveBack,
    moveAndResetStack,
    showSupport,
    hideSupport,
    startLoading,
    stopLoading
} from './src/store/actions/index';
import { Notifications } from 'expo';

import { StyleProvider } from 'native-base';
import getTheme from './native-base-theme/components';
import platform from './native-base-theme/variables/platform';

// reducers
import routesReducer from './src/store/reducers/routes';

// Global headers
import AppNavigator from './AppNavigator';
import { State } from './src/modules/State';
import events from './src/events/events';

const navReducer = (state,action) => {
    const newState = AppNavigator.router.getStateForAction(action, state);
    return newState || state;
}


const appReducer = combineReducers({
    ...
});

const middleware = createReactNavigationReduxMiddleware(
    "root",
    state => state.nav,
);

const addListener = createReduxBoundAddListener("root");


class App extends Component {

    constructor() {
        super();
        this.state = {
            isReady: false,
        }
    }

    async componentWillMount()
    {
        this.setState({isReady: true});

        Notifications.addListener(this.handleNotification)
    }

    handleNotification(notification)
    {
        events.publish('displayNotification', notification);
    }


    render()
    {
        if (!this.state.isReady) {
            return <Expo.AppLoading /> ;
        }
        return (
            <Root>
                <StyleProvider style={getTheme(platform)}>
                    <AppNavigator navigation={addNavigationHelpers({
                        dispatch: this.props.dispatch,
                        state: this.props.nav,
                        addListener,
                    })} />
                </StyleProvider>
            </Root>
        );
    }
}


const mapStateToProps = (state) => ({
    nav: state.nav
});


const AppWithNavigationState = connect(mapStateToProps, null)(App);

let composeEnhancers = compose;

if (__DEV__) {
    composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
}

const ww = createWw(appReducer, composeEnhancers(applyMiddleware(thunk, middleware)));

export default class Top extends Component {
    render() {
        return (
            <Provider ww={ww}>
                <AppWithNavigationState />
            </Provider>
        );
    }
}

1 个答案:

答案 0 :(得分:0)

看看文件'./src/store/actions/index'和'./src/events/events' 似乎有些东西没有从那里正确导出。