question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Offer Link wrapper component in TSX

See original GitHub issue

The styled and wrapped version of the Next.js Linkcomponent provided by the Material UI next-js template/example is not 100% usable in TypeScript projects because IntelliSense does not work with the current JavaScript version of the component. For example, there are no suggestions available for its props.

I converted the JS version to TSX partially. It is usable and IntelliSense works in VS-Code. I am missing just one more type, as far as I can tell. I’ve noted it with a TODO comment in this code gist.

  • I have searched the issues of this repository and believe that this is not a duplicate.

Summary 💡

The Link component should be usable in other TSX components and provide IntelliSense in editors like VS-Code.

Examples 🌈

image

Motivation 🔦

I, like many others, prefer TypeScript over JavaScript and this is the only official starter template for Next.js + Material UI, but it is only JS-oriented. At the moment, the Next.js template only contains a few demo components which will be deleted anyway, but the Link component is usable. It would be great if there was a TSX version of it as well.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Avi98commented, Oct 1, 2020

@oliviertassinari, I can take this issue if @brokenthorn is not looking into it.

0reactions
brokenthorncommented, Oct 9, 2020

@brokenthorn I’m not sure to follow. Are you reporting an issue with?

https://github.com/mui-org/material-ui/blob/814fb60bbd8e500517b2307b6a297a638838ca89/examples/nextjs-with-typescript/src/Link.tsx#L37-L39

Sorry I’m late. I had other pressing projects keeping me busy (and tired).

Yes, that is what I was referring to. The nextjs-with-typescript example had/has a custom Link component that wraps Next.js’s Link component, and that custom component was unusable in TS projects. The gist I gave tried to fix that.

Anyway I’m still busy on another project so it will be a while until I get back to this. This stemmed from a personal project which is now on hold.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Use Wrappers in Typescript React - Twilio
The wrapper is an object that is used to maximize code reuse and consistency. They are used to create and support basic UI...
Read more >
How To Create Wrapper Components in React with Props
Wrapper components are components that surround unknown components and provide a default structure to display the child components.
Read more >
How to write a Typescript React Component Wrapper
Try this, importing ReactChildren from react. I wish i could explain this better, but i know typescript is expecting a JSX/TSX element, ...
Read more >
Proposal: "Wrapper" component for groups of routes in folders ...
I'm proposing that there's some kind of "wrapper" component for groups of routes ... layout component based on router.pathname in _app.tsx .
Read more >
Useful Patterns by Use Case - React TypeScript Cheatsheets
Wrapping /Mirroring a HTML Element​. Usecase: you want to make a <Button> that takes all the normal props of <button> and does extra...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found