menu
announcement

Spectrum is now read-only. Learn more about the decision in our official announcement.

TypeScript

A place to talk about TypeScript.

Channels
Team

Help with type definition of "as" prop with react

August 19, 2020 at 1:17pm

Help with type definition of "as" prop with react

August 19, 2020 at 1:17pm (Edited 1 year ago)
Hello people
I need help to create a typing for "as" prop like the one in styled-components.
I need to create a Button component that receives an "as" prop that can be any other type of react component (like theLink from the react-router library). I need to keep all the props that the Link component of the react-router and also keep the props of theLink component. I'm not getting to this solution, could you help me?
Example:
import { Link } from 'react-router-dom'
<Button as={Link} to="/home" kind="primary">Button</Button>
Thank you!

August 19, 2020 at 3:48pm
also see

Help with type definition of "as" prop with react

message-simple
5
like-fill
1