-
Notifications
You must be signed in to change notification settings - Fork 27k
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
WithRouterProps types not available #7311
Comments
You were probably using |
I'm seeing this as well with 8.1.1-canary.28.
|
As said |
I was able to update to use the new typings and wanted to share my solutions: My component that was being wrapped by I was using If there is a better way to achieve these things, I'd be interesting in learning about them. |
The same problem with |
@ahutchings guidance worked for me. however i think withRouterProps probably ought to be exported too. however, assuming this proposal is not accepted, there's a minor type issue with import axios from "axios"
import Link from "next/link"
import Head from "next/head"
import { withRouter, PublicRouterInstance } from "next/router"
type Type = React.FC<{ router: PublicRouterInstance; posts: any }> & { getInitialProps: any }
const Home: Type = ({ posts }) => {
return (
<div>
<Head>
<title>Next on Netlify</title>
</Head>
{posts.map((post) => (
<div key={post.id}>
<Link href={`/post?id=${post.id}`} as={`/posts/${post.id}`} passHref>
<a>{post.title}</a>
</Link>
</div>
))}
</div>
)
}
Home.getInitialProps = async (props) => {
if (props.res) {
console.log("setHeader")
props.res.setHeader("Cache-Control", "public, s-maxage=30, stale-while-revalidate")
}
console.log(props.asPath, props.query)
const { data } = await axios.get("https://netlify-json-api.netlify.com/posts")
return { posts: data }
}
export default withRouter(Home)
|
The file: contains the WithRouterProps type! But why can't it be imported?
|
Cannot find module
|
@khusamov import { WithRouterProps } from "next/dist/client/with-router"; |
Would love to have |
Please open any requests as new issues, as it's really hard to track comments on closed issues. |
"You were probably using @types/next which is not part of Next.js core and community maintained, it does not reflect the types that we want to provide out of the box." vercel/next.js#7311
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
After upgrading from Next 8.1.0 to 8.1.1 Canary the typescript type definition for WithRouterProps is not there anymore. In the previous version the following statement worked.
import { withRouter, WithRouterProps } from 'next/router';
During the 8.1.1 Canary development iteration withRouter was changed a bit. What is the approach to get those types back again.
The text was updated successfully, but these errors were encountered: