Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useLiveQuery - MissingAPIError: IndexedDB API missing. #1472

Closed
jMoulis opened this issue Jan 8, 2022 · 4 comments
Closed

useLiveQuery - MissingAPIError: IndexedDB API missing. #1472

jMoulis opened this issue Jan 8, 2022 · 4 comments

Comments

@jMoulis
Copy link

jMoulis commented Jan 8, 2022

Hello,
I'm using useLiveQuery and everytime I refresh the page I have this error MissingAPIError: IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb

export const Tracks = () => {
  const tracks = useLiveQuery(() => db.tracks.toArray());
  return (
      <List>
        {loading === 'FALSE' && tracks?.length
          ? tracks?.map((travel, key) => (
              <TrackItem track={travel} key={key}  />
            ))
          : null}
      </List>
  );
};

nextjs: 12.0.7
react: 17.0.2
dexie: ^3.2.1-beta.2
dexie-react-hooks: ^1.1.1

What do I do wrong?

@dfahlander
Copy link
Collaborator

That error happens in node where indexeddb is not available. I assume the code executes in server side rendering in nextjs. Can you instruct nextjs to not render that part server side?

@jMoulis
Copy link
Author

jMoulis commented Jan 15, 2022

Thanks for replying. I tried different approach but none worked so I made a kind of listener based on service worker onmessage, sorry I’m too new to nextjs. But thank you so much for you work

@jMoulis jMoulis closed this as completed Jan 15, 2022
@davigmacode
Copy link

Same problem, this is how i resolve, disable ssr at page level

import dynamic from "next/dynamic"

export const Page: FC = () => {
  return (
    <Tracks/>
  )
}

const Tracks = () => {
  const tracks = useLiveQuery(() => db.tracks.toArray());
  return (
      <List>
        {loading === 'FALSE' && tracks?.length
          ? tracks?.map((travel, key) => (
              <TrackItem track={travel} key={key}  />
            ))
          : null}
      </List>
  );
};

export default dynamic(() => Promise.resolve(Page), { ssr: false });

@dfahlander
Copy link
Collaborator

Upgrade dexie-react-hooks to latest and everything should just work without having to use dynamic import.

(fixed in #1675)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants