0

New to Typescript and React, I'm getting a lint error

Type '({ Token }: { Token: string; }) => JSX.Element' is not assignable to type 'ReactNode'..

 {ClientComponent}
const ClientComponent = ({Token}: {Token: string}) => {
  return (
    <div>
      {Token ? <div>Customer exists</div> : null}
    </div>
  )
}

What is the best way to fix this error? Thank you

2
  • {ClientComponent} what is that? Please show where and how you use this component. Commented Nov 17, 2022 at 18:43
  • in a function return eg: return ( <div className="relative"> {ClientComponent} </div> ); -- Thanks Commented Nov 17, 2022 at 18:59

1 Answer 1

1

You should use components as Tags, not just by the name

Your code should be changed from

return ( <div className="relative"> {ClientComponent} </div> )

to

return ( <div className="relative"> { <ClientComponent token={ tokenVar } /> } </div> )

Please make sure to change tokenVar to whatever the variable name you have your token.

Sign up to request clarification or add additional context in comments.

5 Comments

Thank you, then I get the following error "Property 'Token' is missing in type '{}' but required in type '{ Token: any; }'"
Sorry I missed that. I've changed the answer. Please make sure to change tokenVar to whatever the variable name you have your token.
And mark the answer as the accepted answer is this solved your issue
It helped not quite solved, gives error "Cannot find name 'myVariable'."
What is myVariable? Where have you used it?

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.