Replies: 1 comment
-
The button should have an attribute to change the The temporal solution is. Add to your form this hidden button: {Platform.OS === 'web' && (<button type="submit" className="hidden" />)} Also create an extra component called import { Platform } from 'react-native';
export default function UForm({
children,
...props
}: React.FormHTMLAttributes<HTMLFormElement>) {
if (Platform.OS === 'web') {
return (<form {...props}>{children}</form>);
}
return children;
} Now create your form in this way using https://react-hook-form.com/get-started#ReactNative <UForm onSubmit={handleSubmit(onSubmit)}>
{/* Here your inputs */}
<Button onSubmit={handleSubmit(onSubmit)}>
<ButtonText>
Save
</ButtonText>
</Button>
{Platform.OS === 'web' && (<button
type="submit"
className="hidden"
/>)}
</UForm> |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, how can I use the Form controls with an actual HTML form? I can't set a type=submit property on buttons, and there's no Form component either.
Beta Was this translation helpful? Give feedback.
All reactions