I am trying to render Apple Button on Signup and Sign in screen and I have created the component for the same so that I can reuse the component in the login and Sign up screen but I need to send a prop which buttonType so that I can render button according to screen.
for eg:
<View style={{ margin: 50, marginBottom: 10 }}>
<AppleSignButton buttontype={"AppleButton.Type.SIGN_UP"} />
</View>
But I am getting an error if I am trying this.
Error: Invariant Violation: requireNativeComponent: "RNAppleAuthButtonViewManagerWhiteAppleButton.Type.SIGN_IN" was not found in the UIManager.
AppleButton Component:
<AppleButton
buttonStyle={AppleButton.Style.WHITE}
buttonType={props.buttontype} /* here if I try to replace it with "AppleButton.Type.SIGN_IN" then it outputs same error */
style={{
width: 200,
height: 50,
}}
onPress={() => onAppleButtonPress()}
/>
Now, If I simply replace props.buttontype or "AppleButton.Type.SIGN_IN" this by AppleButton.Type.SIGN_IN it works fine.
So, my guess is that the prop I am sending to the component is in string format that's why the same error comes.
AppleButton Component:
export declare enum AppleButtonType {
/**
* The default button, the same as `SIGN_IN`.
*/
DEFAULT = 'SignIn',
/**
* Renders the button with 'Sign in with Apple'.
*/
SIGN_IN = 'SignIn',
/**
* Renders the button with 'Continue with Apple'.
*/
CONTINUE = 'Continue',
/**
* Renders the button with 'Sign up with Apple'.
*
* > Note: This only works on iOS 13.2+. To check if the current device supports this, use the
* provided `isSignUpButtonSupported` flag from the AppleAuth module.
*/
SIGN_UP = 'SignUp',
}