fireproof-storage / fireproof

Realtime database, runs anywhere. Install Fireproof in your front-end app or edge function, and sync data via any backend.
https://fireproof.storage
Other
282 stars 16 forks source link

create-react-app bundle bug #2

Open jchris opened 1 year ago

jchris commented 1 year ago

For some reason create react app isn't "seeing through" the use-fireproof dependency to grab @fireproof/core properly.

Instead you have to initialize and pass in your own database and index objects. This incantation will work anywhere, but is a required workaround for CRA:

import { useFireproof } from 'use-fireproof'
import { fireproof, index } from '@fireproof/core'
function App() {
  const { database, useLiveQuery } = useFireproof(fireproof('legendary'))
  const sorted = useLiveQuery(index(database, 'sort'))

In normal application, you can omit the fireproof() and index() wrapper and useFireproof and useLiveQuery will just do the correct thing. See #1 about fixing the build bundle.