在此先感谢我目前正在使用西瓜数据库,并且我已根据文档对其进行了配置。如何将数据库从index.js传递到我的组件
index.js
import { AppRegistry } from 'react-native';
import {App} from './App';
import { name as appName } from './app.json';
import { Database } from "@nozbe/watermelondb";
import SQLiteAdapter from "@nozbe/watermelondb/adapters/sqlite";
import { dbModel } from "./src/model"
import { mySchema } from "./src/model/schema"
const adapter = new SQLiteAdapter({
dbName: "myDB",
schema: mySchema
});
const database = new Database({
adapter,
modelClasses: [dbModel],
actionsEnabled: true,
});
AppRegistry.registerComponent(appName, () => App);
应用程序.js
import * as React from 'react';
import { Provider } from 'react-redux';
import { AppWithSidebar } from './src/components';
import configureStore from './src/store/configureStore';
const store = configureStore();
export default () => (
<Provider store={store} >
<AppWithMenu/>
</Provider >
);
在 App.js 中,我有我的 Route 及其组件。我如何将数据库从 index.js 传递到我的组件屏幕。我还需要在我的路由中将它传递到组件屏幕,我的路由看起来像
<Route path="/mytable" component={TableScreen} />