Giter VIP home page Giter VIP logo

next-define's Introduction

Hey, I'm Ben ๐Ÿ‘‹

I'm a 26 year old full-stack engineer & games developer

โšก๏ธ Current

Currently working on building RONIN

๐Ÿ’Ž Experience

I like to say that I am a full-stack developer, but I have most experience with frontend development, primarily React & Vue.js. However for the past few years I have been focusing a lot more on backend development, primarily using TypeScript & Rust.

Following from this, I spent 4 years studying Computer Games Programming at Staffordshire University, focusing on low-level programming using C++ & specializing on advanced graphics using industry standard frameworks such as DirectX & OpenGL.

๐Ÿ“ซ Contact

For a fast response, please DM me on Twitter: @nurodev

Any other queries you can contact me via LinkedIn or via my website: nuro.dev

next-define's People

Contributors

dependabot[bot] avatar nurodev avatar

Stargazers

 avatar  avatar

Watchers

 avatar

next-define's Issues

Fix `definePage` prop type inference bug

What's the issue?

Currently when using definePage, either for the pages/ or app directory, if you add any argument to the handler, like to get the params from getStaticPaths or accessing the req for getServerSideProps, then the inferred props for Component break.

To break down what I have worked out so far:

  • The order you add additional properties to the options parameter can affect whether the type inference works (See example).
    • My guess is some kind of loop hierarchy bug where because getServerSideProps is before Component it knows to check for inferred props first, but when getServerSideProps is defined after Component it doesn't know getServerSideProps exists to fails over to the default of Record<string, any>?
  • Only happens when adding a parameter to a handler function, like { params } to getStaticProps.

TS Playground example

I also tried creating a discriminated union type to work around the issue but somehow it broke even more.
image

Example

โœ… This one works perfectly fine

const { Component, getServerSideProps } = defineSSR({
	getServerSideProps: (ctx) => ({ props: { foo: "bar" } }),
	Component: (props) => <>Hello {props.foo}</>,
});

โŒ This one does not & sets props to Record<string, any>

const { Component, getServerSideProps } = defineSSR({
	Component: (props) => <>Hello {props.foo}</>,
	getServerSideProps: (ctx) => ({ props: { foo: "bar" } }),
});

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.