Open shivjoshi1996 opened 10 months ago
Update on this, I managed to get this kinda working. I also realized I wasn't passing {...props} into the Custom component. The example in the docs doesn't show this, and it would be nice to add this there.
Here's the current WIP code:
Root _layout.tsx
<Authenticator.Provider>
<Authenticator
components={{
SignUp: (props) => {
return <MySignUp {...props} />;
},
}}
services={{
handleSignUp: ({ username, password, options }: SignUpInput) =>
signUp({
username,
password,
}),
}}
>
<Slot />
</Authenticator>
</Authenticator.Provider>
Custom SignUp component
const MySignUp = (props) => {
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
const [confirmPassword, setConfirmPassword] = useState("");
const [isTermsAccepted, setIsTermsAccepted] = useState(false);
const { handleSubmit, toSignIn } = props;
const handleSignUp = async () => {
if (!isTermsAccepted) {
console.log("Terms not accepted");
return;
try {
console.log("Signing Up...");
await signUp({ username, password });
} catch (error) {
console.error("Error signing Up:", error);
}
};
return (
<View>
<Input
placeholder="Email"
onChangeText={(text) => setUsername(text)}
value={username}
autoComplete="email"
/>
<Input
placeholder="Password"
secureTextEntry={true}
onChangeText={(text) => setPassword(text)}
value={password}
/>
<Input
placeholder="Confirm Password"
secureTextEntry={true}
onChangeText={(text) => setConfirmPassword(text)}
value={confirmPassword}
/>
<CheckBox
title="I have read the Terms and Conditions"
checked={isTermsAccepted}
onPress={() => setIsTermsAccepted(!isTermsAccepted)}
/>
<Button
onPress={handleSignUp}
>
Sign Up
</Button>
<Button onPress={toSignIn}>Create an account</Button>
</View>
);
};
A couple of questions I have:
<Authenticator.SignUp.FormFields />
in my custom component, and it rendered the fields fine, but I'm not sure how to get the values from those fields when calling the signIn function. signUp
. I want to make sure it matches the other Authenticator UI, is there an good way to do this?handleSubmit
in my handleSignUp
call, as I've seen in this ticket: https://github.com/aws-amplify/amplify-ui/issues/4939, and had to use await signUp({ username, password });
instead, although I know this isn't the way to go. Any idea why handleSubmit
won't work? Is there a piece I'm missing here? I'm still trying to figure out how to use this library effectively, so if there is a better way to do any of this, please let me know! Thanks.
Thank you for your feature request. We are considering adding this feature to the roadmap for the next version of RN Authenticator.
On which framework/platform would you like to see this feature implemented?
React Native
Which UI component is this feature-request for?
Authenticator
Please describe your feature-request in detail.
Hi there,
I'm currently using the React Native Authenticator component, and I'm trying to implement a sign up page with a T&C's checkbox, similar to the one described in the Amplify React docs here, but I'm having some trouble with figuring out if this is possible with the React Native package.
I've tried a couple of ways:
When I try to do something like this, the checkbox doesn't show below the form fields. It does show up if I move it outside of the
Authenticator
component. If I remove theAuthenticator
component the Sign Up form fields fail to show up. Am I doing something wrong? Or is this not currently possible with the React Native package?Example code for the custom SignUp component:
Passed into the Authenticator component, in my root _layout file.
The fields array doesn't support a
type
ofcheckbox
so I'm not sure if this way is even feasible.Does anyone have any thoughts on how I would achieve this?
Thanks!
Please describe a solution you'd like.
We love contributors! Is this something you'd be interested in working on?