@nozbe/watermelondb
Version:
Build powerful React Native and React web apps that scale from hundreds to tens of thousands of records and remain fast
18 lines (13 loc) • 445 B
JavaScript
// @flow
import React from 'react'
import { DatabaseContext } from '../DatabaseProvider'
import invariant from '../utils/common/invariant'
import type Database from '../Database'
export default function useDatabase(): Database {
const database = React.useContext(DatabaseContext)
invariant(
database,
'Could not find database context, please make sure the component is wrapped in the <DatabaseProvider>',
)
return database
}