score:1
Accepted answer
antd-mobile
is based on react native. it's used a little bit differently for react components.
an example usage of useform
for react native components is below:
import react from "react";
import { text, view, textinput, button, alert } from "react-native";
import { useform, controller } from "react-hook-form";
export default function app() {
const { control, handlesubmit, errors } = useform();
const onsubmit = data => console.log(data);
return (
<view>
<controller
control={control}
render={({ onchange, onblur, value }) => (
<textinput
style={styles.input}
onblur={onblur}
onchangetext={value => onchange(value)}
value={value}
/>
)}
name="firstname"
rules={{ required: true }}
defaultvalue=""
/>
{errors.firstname && <text>this is required.</text>}
<controller
control={control}
render={({ onchange, onblur, value }) => (
<textinput
style={styles.input}
onblur={onblur}
onchangetext={value => onchange(value)}
value={value}
/>
)}
name="lastname"
defaultvalue=""
/>
<button title="submit" onpress={handlesubmit(onsubmit)} />
</view>
);
}
for reference, please check the documentation here.
Source: stackoverflow.com
Related Query
- Why is there no submit button in Ant Design Mobile?
- Why is there no onchange for `<Input>` in Ant design
- ant design - Modal value reset on "cancel" and "X" close button - API RESPONSE BASE REACT JS
- ReactJS Ant Design - Open DatePicker on button click
- How to disable button in Ant Design Input.Search component
- Ant Design form element is not submitting when the form button is clicked
- Why won't custom input controls validation properly in Ant Design forms?
- How to correctly validate and submit if form is valid with ant design form with typescript
- Is there a way to test Ant Design Modal parameter methods?
- how to display icon in center in ant design Button
- Is there a way to normalize values of a ant design input on submit?
- Button within a tab to switch tabs using Ant Design in React?
- Can Ant Design form validation be skipped upon clicking the submit button?
- Why does react form's onSubmit fire after every keystroke, how to use enter button to submit form?
- Why is Ant design less styles not applied in nextjs app with Webpack5?
- Change Modal button texts in Ant Design
- Ant design Tree defaultExpandAll doesnt work with button click for react
- How override a Button Ant Design with styled component and typescripts?
- Unable to update the state when button inside table cell clicked , React Ant Design
- Why won't the form state visibly change within the submit button using react form hook?
- How can I remove the magnifying glass button from an Ant Design input search box?
- Why ant design Drawer not showing close icon?
- Ant design Button shape and color are not applied
- How to call useNavigate inside useEffect? - For bottom navigation in Ant Design - Mobile
- Why do I have to click Submit button TWICE in order to update my useState() hook?
- Ant design Collapse - expand / collapse all button
- React js - Ant Design switch changing although Ok button is not pressed
- Why in my ant design does not work defaultOpenKeys?
- ant design Tab switching when button is presssed
- Why is not tree checkboxes checked in the child component using Ant Tree Design
More Query from same tag
- How to create selects and states dynamically on react using Material UI?
- Leaflet ReactJS Map does not show tile completely
- How To Toggle object in array with React Hooks i want to toggle className ".card like" and "card dislike" with button className"card-button"
- React defining functions at file scope in functional component
- Should we use BEM(Block, Element, Modifier) in react styled component
- Way to test the order of elements in React
- REACT- How to set enddate same as startdate by default but control if enddate not before startdate?
- react : Unhandled Rejection (SyntaxError): Unexpected token < in JSON at position 0
- Is this discouraged for HOC in React?
- How do I change the bar colors on Ant Design Chart
- reactJs test mocked component input and reponse, where to start?
- How to pass class props to function in reactjs
- Create HTML file from React components
- Google-Map-React - Javascript: How to click on a customized marker
- Single ant upload list item only
- Can print out value, but in setState its "undefined"
- react onsenui mocha test error "Error: Invalid state"
- Why Redux Strore does not add new entry
- React - "TypeError: Cannot read property 'image' of undefined" while styling with CSS
- How to use firebase stored vidoes in reactjs
- How to write an ES6 class React Component that extends a functional component?
- Convert dataURL/Buffer to blob
- React conditional rendering of JSX
- Cannot call one action from another in a React-Redux app
- Do not mutate state directly, Use setState() react/no-direct-mutation-state in React JS
- Add custom attribute to JSX
- material-ui : Extract color from theme
- react native: There is way to fix the check boxes in my example?
- Form submit only submits on the 2nd click, need callback in ES6
- Is there a way to avoid re-render continuously when calling a WebSocket from React component?