Skip to content

as Prop not working with derived component #56

Pinned Answered by sannajammeh
maltesa asked this question in Q&A
Discussion options

You must be logged in to vote

Hello!

This issue is caused by the React internal typings as somehow manage to flatten the type of BasicButton. Any library using polymorphism seems to have this problem.

Its an easy fix though! What you need to do is re-map the button after its created. Like so:

Edit 3 - Now fixed

Released a fix in Canary npm i @tw-classed/react@canary
See the Creating a derived component docs.

import type { DerivedComponentType } from "@tw-classed/react";

export const Button = forwardRef<HTMLButtonElement, Props>(function Button(
  { children, ...props },
  ref
) {
  return (
    <BasicButton {...props} ref={ref}>
      {/*
        Do stuff here.
        E.g. extend props with icon?: SVGSVGElement prop…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by sannajammeh
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants