2

I need to extend React.FC with custom interface like this:

interface IComponent<P = {}> extends React.FC {
  custom?: {a: string, b: string};
}

const Page:IComponent<{text: string}> = ({text}) => (
  <>{text}</>
)

Page.custom = {a: '1', b: '2'}

Page.custom is typed correctly, but React.FC props functionality is lost. How do I fix this?

0

2 Answers 2

3

Figured that out. I needed to pass P param from IComponent to React.FC

interface IComponent<P = {}> extends React.FC<P> {
  custom?: {a: string, b: string};
}
Sign up to request clarification or add additional context in comments.

1 Comment

0

try withoutt {}

add type string


interface IComponent<P = {}> extends React.FC {
  custom?: {a: string, b: string};
}

const Page:IComponent<{text: string}> = (text:string) => (
  <>{text}</>
)

Page.custom = {a: '1', b: '2'}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.