我正在阅读没有create-react-native应用程序编写的教程,它使用了exponent ..我在教程中看到的代码是:
let React = require('react-native')
let { AppRegistry, Component,Text} = React;
class .....{
render(){return();}
}
AppRegistry.registerComponent('main',()=> className);
因为AppRegistry似乎不起作用,因为我使用的是create-react-native应用程序并且我不想弹出,我可以使用什么而不是AppRegistry?
答案 0 :(得分:0)
在我的App.js中,我只导出一个根组件:
import React, { Component } from 'react';
import { View } from 'react-native';
import firebase from 'firebase';
import ReduxThunk from 'redux-thunk';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import AppWithNavigationState from './app/components/AppWithNavigationState';
import settings from './app/config/settings';
import reducers from './app/reducers';
export default class Root extends Component {
componentWillMount() {
const {
dev,
DEVELOPMENT,
PRODUCTION,
} = settings;
firebase.initializeApp({
apiKey : dev ? DEVELOPMENT.FIREBASE_APIKEY : PRODUCTION.FIREBASE_APIKEY,
authDomain : dev ? DEVELOPMENT.FIREBASE_AUTHDOMAIN : PRODUCTION.FIREBASE_AUTHDOMAIN,
databaseURL : dev ? DEVELOPMENT.FIREBASE_URL : PRODUCTION.FIREBASE_URL,
projectId : dev ? DEVELOPMENT.FIREBASE_PRODUCT_ID : PRODUCTION.FIREBASE_PRODUCT_ID,
storageBucket : dev ? DEVELOPMENT.FIREBASE_STORAGEBUCKET : PRODUCTION.FIREBASE_STORAGEBUCKET,
messagingSenderId : dev ? DEVELOPMENT.FIREBASE_MESSAGING_ID : PRODUCTION.FIREBASE_MESSAGING_ID,
});
}
render() {
const store = createStore(reducers, {}, applyMiddleware(ReduxThunk))
return (
<Provider store={store}>
<View style={{ flex: 1 }}>
<AppWithNavigationState />
</View>
</Provider>
);
}
}