You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 1, 2023. It is now read-only.
I found the create-react-library library and wanted to use it to create a library for wallets.
i've created a component that has conditional props depending of the type provided.
something like this in the types :
export type CardAndroidProps =
| CardAndroidStore
| CardAndroidEvent
export type CardAndroidStore = {
type: 'store';
backgroundColor: string;
} ;
export type CardAndroidEvent= {
type: 'event';
mainTitle: string;
} ;
This way when the user calls the component and tries to pass props, depending on the type value he will be notified by the missing prop or that a prop does not exist on a the type. so this part works fine.
The problem happens when trying to call "props.mainTitle" or "props.backgroundColor" in the component source code, i get this error in the compiler "Property 'mainTitle' does not exist on type" but nothing in the IDE (VScode in my case).
I had to use "//@ts-ignore" each time i need to call a prop.
//@ts-ignore
console.log(props.mainTitle)
Is there a problem with the library compiler not allowing conditional props ? or is it a problem in my code ?
Thx in advance.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I found the create-react-library library and wanted to use it to create a library for wallets.
i've created a component that has conditional props depending of the type provided.
something like this in the types :
This way when the user calls the component and tries to pass props, depending on the type value he will be notified by the missing prop or that a prop does not exist on a the type. so this part works fine.
The problem happens when trying to call "props.mainTitle" or "props.backgroundColor" in the component source code, i get this error in the compiler "Property 'mainTitle' does not exist on type" but nothing in the IDE (VScode in my case).
I had to use "//@ts-ignore" each time i need to call a prop.
Is there a problem with the library compiler not allowing conditional props ? or is it a problem in my code ?
Thx in advance.
The text was updated successfully, but these errors were encountered: