Giter Site home page Giter Site logo

Comments (4)

FINDarkside avatar FINDarkside commented on August 29, 2024 2
// Page component
export default function () {
  return <WrappedComponentWithRelay />;
}

That's not going to work because withRelay needs to be used to wrap the Page component.

If you want to pass stuff to deeper components you should make graphql fragments and then load the data with useFragment.

from relay-nextjs.

8byr0 avatar 8byr0 commented on August 29, 2024

@FINDarkside Yes it's a mistake in my code which I did not make when testing out with the example project :

// Add this default export instead
export default function (props: any) {
  console.log('props', props);
  return <MyNestedComponent {...props} />;
}

I think I actually figured out the problem, withRelay can only be used around page components because it involves getServerSideProps which can only be used on root page components. This is why even forwarding all the props don't work as expected. (see https://stackoverflow.com/a/64138369/9568373). Am I right?

from relay-nextjs.

FINDarkside avatar FINDarkside commented on August 29, 2024

You're right that it needs to be used with page components only. Small technical difference is that it doesn't use getServerSideProps though, but getInitialProps :) But it also works only with page components as you said.

from relay-nextjs.

8byr0 avatar 8byr0 commented on August 29, 2024

Yes, my bad. And I actually feel ashamed cause it was written in the docs
https://reverecre.github.io/relay-nextjs/docs/page-api#arguments :

component: A Next.js page component to recieve the preloaded query from relay-nextjs.

#RTFM

TL;DR;

For anyone coming here with the same problem:

withRelay HOC can only be used with NextJS page components

from relay-nextjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.