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

useData() - Error with new vike project #115

Closed
exceptionptr opened this issue May 27, 2024 · 7 comments
Closed

useData() - Error with new vike project #115

exceptionptr opened this issue May 27, 2024 · 7 comments
Labels
bug 💥 Something isn't working

Comments

@exceptionptr
Copy link

pages/+data.ts

async function data() {
  const result = await fetch('https://pokeapi.co/api/v2/pokemon/pikachu');
  const data = await result.json();

  return data;
}

export { data };

pages/+Page.tsx

import { useData } from 'vike-react/useData';

function Page() {
  const data = useData<unknown>();
  return <>{JSON.stringify(data)}</>;
}

export default Page;

+renderer/config.ts

import type { Config } from 'vike/types';
import vikeReact from 'vike-react/config';

export default {
  clientRouting: true,

  meta: {
    title: {
      env: { server: true, client: true },
    },

    description: {
      env: { server: true, client: false },
    },
  },

  hydrationCanBeAborted: true,

  extends: vikeReact,
} satisfies Config;

localhost-1716830984490.log

@brillout brillout added the bug 💥 Something isn't working label May 27, 2024
@brillout
Copy link
Member

I'll need a reproduction, with reproduction steps.

@exceptionptr
Copy link
Author

I'll need a reproduction, with reproduction steps.

https://github.com/0x2aff/vike-demo-project

@brillout
Copy link
Member

👍 Let me have a look.

@brillout
Copy link
Member

The issue is that you're using your own onRenderClient()/onRenderHtml() hooks.

What is it you're trying to achieve?

@exceptionptr
Copy link
Author

Oh that makes sense.
I want to use SSR only for OpenGraph tags, but the rest of the application should be CSR.

@brillout
Copy link
Member

Set ssr: false while using the Head setting.

@exceptionptr
Copy link
Author

Thank you! This can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 💥 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants