{"id":349988,"date":"2023-07-09T03:00:26","date_gmt":"2023-07-09T03:00:26","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=349988"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=349988","title":{"rendered":"<span>\u041a\u0430\u043a \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e React Hook Form<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e, \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438! \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0444\u043e\u0440\u043c \u043d\u0430 React &#8212; React Hook Form. \u041a\u043e\u0433\u0434\u0430 \u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u044f \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0448\u0438\u0431\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c.  <\/p>\n<h2>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0435\u043e\u0442\u0435\u043a\u0438<\/h2>\n<ol>\n<li>\n<p>React <strong>18.2.0<\/strong><\/p>\n<\/li>\n<li>\n<p>React Hook Form <strong>v7.45.1<\/strong><\/p>\n<\/li>\n<li>\n<p>Material UI <strong>v5.13.7<\/strong><\/p>\n<\/li>\n<li>\n<p>Axios <strong>v1.4.0<\/strong><\/p>\n<\/li>\n<li>\n<p>JSON server <strong>v0.17.3<\/strong><\/p>\n<\/li>\n<\/ol>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0444\u043e\u0440\u043c\u044b<\/h2>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u043e\u0440\u043c\u0443 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"javascript\">import { Button, TextField } from \"@mui\/material\"; import { Controller, FormProvider, useForm } from \"react-hook-form\"; import \".\/App.css\"  export const App = () => {   const methods = useForm()    const { control, handleSubmit } = methods    const onSave = (data) => {     console.log(data)   }    return (     &lt;FormProvider {...methods}>       &lt;div className=\"card\">         &lt;span>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c&lt;\/span>         &lt;Controller           name=\"name\"           control={control}           render={({ field: { value, onChange } }) => (             &lt;TextField               value={value}               onChange={onChange}             \/>           )}         \/>         &lt;Controller           name=\"suname\"           control={control}           render={({ field: { value, onChange } }) => (             &lt;TextField               value={value}               onChange={onChange}             \/>           )}         \/>       &lt;\/div>       &lt;Button onClick={handleSubmit(onSave)}>\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c&lt;\/Button>     &lt;\/FormProvider>   ); } <\/code><\/pre>\n<p>\u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043a\u043e\u0434\u0435 \u043c\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0445\u0443\u043a <code>useForm<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u043d\u0430\u043c \u043c\u0435\u0442\u043e\u0434\u044b \u0438\u0437 React Hook Form. \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>methods<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043d\u0430\u043c \u043f\u043e\u0437\u0436\u0435.<\/p>\n<p>\u041c\u044b \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u043d\u0430\u0448\u0443 \u0444\u043e\u0440\u043c\u0443 \u0432 <code>FormProvider<\/code> \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0438\u0437 <code>useForm<\/code>, \u043a\u0430\u043a \u043f\u0440\u043e\u043f\u0441\u044b.<\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u0435\u0439 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c <code>Controller<\/code>, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u043c React Hook Form.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0443 \u043d\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0441\u0430\u043c\u0443 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442.<\/p>\n<pre><code class=\"javascript\">import { TextField } from \"@mui\/material\" import { Controller, useFormContext } from \"react-hook-form\"  export const UserCard = () => {     const { control } = useFormContext()      return (         &lt;div className=\"card\">             &lt;span>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c&lt;\/span>             &lt;Controller                 name=\"name\"                 control={control}                 render={({ field: { value, onChange } }) => (                     &lt;TextField                       value={value}                       onChange={onChange}                     \/>                 )}             \/>             &lt;Controller                 name=\"suname\"                 control={control}                 render={({ field: { value, onChange } }) => (                     &lt;TextField                       value={value}                       onChange={onChange}                     \/>                 )}             \/>       &lt;\/div>     ) }<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 <code>Controller<\/code> \u043d\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c <code>control<\/code> \u0438\u0437 \u043d\u0430\u0448\u0435\u0439 \u0444\u043e\u0440\u043c\u044b. \u041d\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>useForm<\/code> \u0441\u043d\u043e\u0432\u0430, \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u0443\u044e \u0444\u043e\u0440\u043c\u0443. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0442\u043e\u0439 \u0436\u0435 \u0444\u043e\u0440\u043c\u044b, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0445\u0443\u043a <code>useFormContext<\/code>. \u041e\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0442\u0435 \u0436\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u0447\u0442\u043e \u0438 <code>useForm<\/code>, \u043d\u043e \u0443\u0436\u0435 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043d\u0430\u0448\u0435\u0439 \u0444\u043e\u0440\u043c\u044b, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0444\u043e\u0440\u043c\u0430 \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u0430 \u0432 <code>FormProvider<\/code>. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0430\u0445\u043e\u0434\u044f\u0441\u044c \u043d\u0430 \u043b\u044e\u0431\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0430\u0448\u0435\u0439 \u0444\u043e\u0440\u043c\u044b, \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u0435\u0435 \u043c\u0435\u0442\u043e\u0434\u044b.<\/p>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0430\u0448\u0430 \u0444\u043e\u0440\u043c\u0430:<\/p>\n<pre><code class=\"javascript\">import { Button } from \"@mui\/material\"; import { FormProvider, useForm } from \"react-hook-form\"; import \".\/App.css\" import { UserCard } from \".\/UserCard\";  export const App = () => {   const methods = useForm()    const { handleSubmit } = methods    const onSave = (data) => {     console.log(data)   }    return (     &lt;FormProvider {...methods}>       &lt;UserCard \/>       &lt;Button onClick={handleSubmit(onSave)}>\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c&lt;\/Button>     &lt;\/FormProvider>   ); } <\/code><\/pre>\n<h2>\u0423\u0447\u0438\u043c\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438 \u0432 \u0444\u043e\u0440\u043c\u0435<\/h2>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0444\u043e\u0440\u043c\u0430 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u0430. \u0412 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0430 \u043f\u043e\u043b\u044f. \u0410 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0439 \u0444\u043e\u0440\u043c\u044b \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 user \u0441 \u043f\u043e\u043b\u044f\u043c\u0438 name \u0438 surname. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 API, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c JSON-server \u0438 \u0441\u043e\u0437\u0434\u0430\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.  <\/p>\n<pre><code class=\"json\">{     \"users\": [         {             \"id\": 1,             \"name\": \"Artem\",             \"suname\": \"Morozov\"         },         {             \"id\": 2,             \"name\": \"Maxim\",             \"suname\": \"Klever\"         },         {             \"id\": 3,             \"name\": \"John\",             \"suname\": \"Weelson\"         }     ] }<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0430\u0448\u0443 \u0444\u043e\u0440\u043c\u0443, \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u0438\u0445 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435.<\/p>\n<pre><code class=\"javascript\">import { useEffect } from \"react\" import { Button } from \"@mui\/material\"; import { FormProvider, useFieldArray, useForm } from \"react-hook-form\"; import \".\/App.css\" import { UserCard } from \".\/UserCard\"; import axios from \"axios\";  export const App = () => {   const methods = useForm({     defaultValues: {       users: []     }   })    const { control, handleSubmit, reset } = methods    const { fields } = useFieldArray({     name: \"users\",     control: control,     shouldUnregister: true   })    const onSave = (data) => {     console.log(data)   }    useEffect(() => {     const getUsersAsync = async () => {       const { data } = await axios.get(\"http:\/\/localhost:3000\/users\")       reset({         users: data       })     }     getUsersAsync()   }, [reset])    return (     &lt;FormProvider {...methods}>       {fields.map((user, index) => (         &lt;UserCard key={user.id} user={user} userIndex={index} \/>       ))}       &lt;Button onClick={handleSubmit(onSave)}>\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c&lt;\/Button>     &lt;\/FormProvider>   ); } <\/code><\/pre>\n<ol>\n<li>\n<p>\u0412 \u0445\u0443\u043a\u0435 useForm \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0443 \u043d\u0430\u0441 \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0445\u0443\u043a useFieldArray ( fields ).  <\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 API \u0438 \u043f\u0435\u0440\u0435\u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0432\u0430\u0435\u043c \u043d\u0430\u0448\u0443 \u0444\u043e\u0440\u043c\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 reset.<\/p>\n<\/li>\n<li>\n<p>\u0418, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0438\u0441\u0430\u043b\u0438\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043d\u0430\u0448\u0435\u0433\u043e API.  <\/p>\n<\/li>\n<\/ol>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u043e\u0434 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0438.<\/p>\n<pre><code class=\"javascript\">import { TextField } from \"@mui\/material\" import { Controller, useFormContext } from \"react-hook-form\" import \".\/App.css\"  export const UserCard = (props) => {     const { user: { name, suname }, userIndex } = props     const { control } = useFormContext()      return (         &lt;div className=\"card\">             &lt;div className=\"card__header\">                 &lt;span>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c {userIndex + 1}&lt;\/span>             &lt;\/div>             &lt;Controller                 name={`users[${userIndex}].name`}                 control={control}                 defaultValue={name}                 render={({ field: { value, onChange } }) => (                     &lt;TextField                         value={value}                         onChange={onChange}                     \/>                 )}             \/>             &lt;Controller                 name={`users[${userIndex}].suname`}                 control={control}                 defaultValue={suname}                 render={({ field: { value, onChange } }) => (                     &lt;TextField                         value={value}                         onChange={onChange}                     \/>                 )}             \/>       &lt;\/div>     ) }<\/code><\/pre>\n<ol>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432 Controller \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f defaultValue \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0438\u0437 props.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f \u0442\u0430\u043a\u0436\u0435 name \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044f. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 users &#8212; \u044d\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432, \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043a\u0430\u0445, \u0430 \u0437\u0430\u0442\u0435\u043c name \u0438 surname. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0439\u0442\u0438 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442.<\/p>\n<\/li>\n<\/ol>\n<h2>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u043a\u0430\u0440\u0442\u043e\u0447\u0435\u043a<\/h2>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u043d\u0430\u0448\u0435\u0439 \u0444\u043e\u0440\u043c\u044b &#8212; \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0442\u0435\u043c \u0436\u0435 useFieldArray, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u0438\u043c\u043e fields \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e append \u0438 remove. \u0412\u043e\u0442 \u043a\u0430\u043a \u044f \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b.  <\/p>\n<pre><code class=\"javascript\">import { useEffect } from \"react\" import { Button } from \"@mui\/material\"; import { FormProvider, useFieldArray, useForm } from \"react-hook-form\"; import { UserCard } from \".\/UserCard\"; import axios from \"axios\";  export const App = () => {   const methods = useForm({     defaultValues: {       users: []     }   })    const { control, handleSubmit, reset } = methods    const { append, remove, fields } = useFieldArray({     name: \"users\",     control: control   })    const onSave = (data) => {     console.log(data)   }    const onAddUser = () => {     const lastUser = fields.at(-1)     let newUserId = 1;      if (lastUser) {       newUserId = lastUser.id + 1;     }          append({       id: newUserId,       name: \"\",       suname: \"\"     })   }    const onDeleteUser = (userIndex) => {     remove(userIndex)   }    useEffect(() => {     const getUsersAsync = async () => {       const { data } = await axios.get(\"http:\/\/localhost:3000\/users\")       reset({         users: data       })     }     getUsersAsync()   }, [reset])    return (     &lt;FormProvider {...methods}>       {fields?.map((user, index) => (         &lt;UserCard key={index} user={user} userIndex={index} onDeleteUser={onDeleteUser} \/>       ))}       &lt;Button onClick={onAddUser}>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f&lt;\/Button>       &lt;Button onClick={handleSubmit(onSave)}>\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c&lt;\/Button>     &lt;\/FormProvider>   ); } <\/code><\/pre>\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 id. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 id \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0434\u0438\u043d\u0438\u0446\u0443. \u0421\u0442\u043e\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432 \u0445\u0443\u043a\u0435 useFieldArray \u0431\u044b\u043b\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u043f\u043e\u043b\u0435 keyName \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c key. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e useFieldArray \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0435 id, \u043d\u043e \u0442\u0430\u043a \u043a\u0430\u043a \u0443 \u043d\u0430\u0441 id \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0441 API, \u0430 \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435, \u044d\u0442\u043e\u0442 \u043a\u043b\u044e\u0447 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u0438\u043d\u0430\u0447\u0435, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u043e\u0432.  <\/p>\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 remove, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0438\u043d\u0434\u0435\u043a\u0441 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c. \u0418\u043d\u0434\u0435\u043a\u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0438 \u0432 props.  <\/p>\n<p>\u0418, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f UserCard.<\/p>\n<pre><code class=\"javascript\">import { Button, TextField } from \"@mui\/material\" import { Controller, useFormContext } from \"react-hook-form\" import \".\/App.css\"  export const UserCard = (props) => {     const { user: { name, suname }, userIndex, onDeleteUser } = props     const { control } = useFormContext()      return (         &lt;div className=\"card\">             &lt;div className=\"card__header\">                 &lt;span>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c {userIndex + 1}&lt;\/span>                 &lt;Button onClick={() => onDeleteUser(userIndex)}>\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f&lt;\/Button>             &lt;\/div>              &lt;Controller                 name={`users[${userIndex}].name`}                 control={control}                 defaultValue={name}                 render={({ field: { value, onChange } }) => (                     &lt;TextField                         value={value}                         onChange={onChange}                     \/>                 )}             \/>             &lt;Controller                 name={`users[${userIndex}].suname`}                 control={control}                 defaultValue={suname}                 render={({ field: { value, onChange } }) => (                     &lt;TextField                         value={value}                         onChange={onChange}                     \/>                 )}             \/>       &lt;\/div>     ) }<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043a\u043d\u043e\u043f\u043a\u0443 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u043a\u043b\u0438\u043a\u0435.<\/p>\n<p>\u0411\u043e\u043b\u044c\u0448\u043e\u0435 \u0441\u043f\u0430\u0441\u0438\u0431\u043e, \u0447\u0442\u043e \u0434\u043e\u0447\u0438\u0442\u0430\u043b\u0438 \u0434\u043e \u043a\u043e\u043d\u0446\u0430. \u0411\u0443\u0434\u0443 \u043e\u0447\u0435\u043d\u044c \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u0435\u043d \u0437\u0430 \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u0432\u044f\u0437\u044c \u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0438. \u0420\u0430\u0441\u0441\u043a\u0430\u0436\u0438\u0442\u0435 \u043e \u0441\u0432\u043e\u0435\u043c \u043e\u043f\u044b\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f React Hook Form.<\/p>\n<p>PS: \u0414\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0431\u044b\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 JavaScript \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043a\u043e\u0434\u0430 \u0438 \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0447\u0442\u0435\u043d\u0438\u044f. \u042f \u0442\u0430\u043a\u0436\u0435 \u043d\u0435 \u0441\u0442\u0430\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u043c\u043e\u0438\u0437\u0430\u0446\u0438\u044e useCallback, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u043b\u043e \u0431\u044b \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c. \u0415\u0449\u0435 \u0440\u0430\u0437 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e.  <\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/746806\/\"> https:\/\/habr.com\/ru\/articles\/746806\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e, \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438! \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0444\u043e\u0440\u043c \u043d\u0430 React &#8212; React Hook Form. \u041a\u043e\u0433\u0434\u0430 \u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u044f \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0448\u0438\u0431\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c.  <\/p>\n<h2>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0435\u043e\u0442\u0435\u043a\u0438<\/h2>\n<ol>\n<li>\n<p>React <strong>18.2.0<\/strong><\/p>\n<\/li>\n<li>\n<p>React Hook Form <strong>v7.45.1<\/strong><\/p>\n<\/li>\n<li>\n<p>Material UI <strong>v5.13.7<\/strong><\/p>\n<\/li>\n<li>\n<p>Axios <strong>v1.4.0<\/strong><\/p>\n<\/li>\n<li>\n<p>JSON server <strong>v0.17.3<\/strong><\/p>\n<\/li>\n<\/ol>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0444\u043e\u0440\u043c\u044b<\/h2>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u043e\u0440\u043c\u0443 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"javascript\">import { Button, TextField } from \"@mui\/material\"; import { Controller, FormProvider, useForm } from \"react-hook-form\"; import \".\/App.css\"  export const App = () => {   const methods = useForm()    const { control, handleSubmit } = methods    const onSave = (data) => {     console.log(data)   }    return (     &lt;FormProvider {...methods}>       &lt;div className=\"card\">         &lt;span>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c&lt;\/span>         &lt;Controller           name=\"name\"           control={control}           render={({ field: { value, onChange } }) => (             &lt;TextField               value={value}               onChange={onChange}             \/>           )}         \/>         &lt;Controller           name=\"suname\"           control={control}           render={({ field: { value, onChange } }) => (             &lt;TextField               value={value}               onChange={onChange}             \/>           )}         \/>       &lt;\/div>       &lt;Button onClick={handleSubmit(onSave)}>\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c&lt;\/Button>     &lt;\/FormProvider>   ); } <\/code><\/pre>\n<p>\u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043a\u043e\u0434\u0435 \u043c\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0445\u0443\u043a <code>useForm<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u043d\u0430\u043c \u043c\u0435\u0442\u043e\u0434\u044b \u0438\u0437 React Hook Form. \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>methods<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043d\u0430\u043c \u043f\u043e\u0437\u0436\u0435.<\/p>\n<p>\u041c\u044b \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u043d\u0430\u0448\u0443 \u0444\u043e\u0440\u043c\u0443 \u0432 <code>FormProvider<\/code> \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0438\u0437 <code>useForm<\/code>, \u043a\u0430\u043a \u043f\u0440\u043e\u043f\u0441\u044b.<\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u0435\u0439 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c <code>Controller<\/code>, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u043c React Hook Form.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0443 \u043d\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0441\u0430\u043c\u0443 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442.<\/p>\n<pre><code class=\"javascript\">import { TextField } from \"@mui\/material\" import { Controller, useFormContext } from \"react-hook-form\"  export const UserCard = () => {     const { control } = useFormContext()      return (         &lt;div className=\"card\">             &lt;span>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c&lt;\/span>             &lt;Controller                 name=\"name\"                 control={control}                 render={({ field: { value, onChange } }) => (                     &lt;TextField                       value={value}                       onChange={onChange}                     \/>                 )}             \/>             &lt;Controller                 name=\"suname\"                 control={control}                 render={({ field: { value, onChange } }) => (                     &lt;TextField                       value={value}                       onChange={onChange}                     \/>                 )}             \/>       &lt;\/div>     ) }<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 <code>Controller<\/code> \u043d\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c <code>control<\/code> \u0438\u0437 \u043d\u0430\u0448\u0435\u0439 \u0444\u043e\u0440\u043c\u044b. \u041d\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <code>useForm<\/code> \u0441\u043d\u043e\u0432\u0430, \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u0443\u044e \u0444\u043e\u0440\u043c\u0443. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0442\u043e\u0439 \u0436\u0435 \u0444\u043e\u0440\u043c\u044b, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0445\u0443\u043a <code>useFormContext<\/code>. \u041e\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0442\u0435 \u0436\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u0447\u0442\u043e \u0438 <code>useForm<\/code>, \u043d\u043e \u0443\u0436\u0435 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043d\u0430\u0448\u0435\u0439 \u0444\u043e\u0440\u043c\u044b, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0444\u043e\u0440\u043c\u0430 \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u0430 \u0432 <code>FormProvider<\/code>. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0430\u0445\u043e\u0434\u044f\u0441\u044c \u043d\u0430 \u043b\u044e\u0431\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0430\u0448\u0435\u0439 \u0444\u043e\u0440\u043c\u044b, \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u0435\u0435 \u043c\u0435\u0442\u043e\u0434\u044b.<\/p>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0430\u0448\u0430 \u0444\u043e\u0440\u043c\u0430:<\/p>\n<pre><code class=\"javascript\">import { Button } from \"@mui\/material\"; import { FormProvider, useForm } from \"react-hook-form\"; import \".\/App.css\" import { UserCard } from \".\/UserCard\";  export const App = () => {   const methods = useForm()    const { handleSubmit } = methods    const onSave = (data) => {     console.log(data)   }    return (     &lt;FormProvider {...methods}>       &lt;UserCard \/>       &lt;Button onClick={handleSubmit(onSave)}>\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c&lt;\/Button>     &lt;\/FormProvider>   ); } <\/code><\/pre>\n<h2>\u0423\u0447\u0438\u043c\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438 \u0432 \u0444\u043e\u0440\u043c\u0435<\/h2>\n<p>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0444\u043e\u0440\u043c\u0430 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u0430. \u0412 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0430 \u043f\u043e\u043b\u044f. \u0410 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0439 \u0444\u043e\u0440\u043c\u044b \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 user \u0441 \u043f\u043e\u043b\u044f\u043c\u0438 name \u0438 surname. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 API, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c JSON-server \u0438 \u0441\u043e\u0437\u0434\u0430\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.  <\/p>\n<pre><code class=\"json\">{     \"users\": [         {             \"id\": 1,             \"name\": \"Artem\",             \"suname\": \"Morozov\"         },         {             \"id\": 2,             \"name\": \"Maxim\",             \"suname\": \"Klever\"         },         {             \"id\": 3,             \"name\": \"John\",             \"suname\": \"Weelson\"         }     ] }<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0430\u0448\u0443 \u0444\u043e\u0440\u043c\u0443, \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u0438\u0445 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435.<\/p>\n<pre><code class=\"javascript\">import { useEffect } from \"react\" import { Button } from \"@mui\/material\"; import { FormProvider, useFieldArray, useForm } from \"react-hook-form\"; import \".\/App.css\" import { UserCard } from \".\/UserCard\"; import axios from \"axios\";  export const App = () => {   const methods = useForm({     defaultValues: {       users: []     }   })    const { control, handleSubmit, reset } = methods    const { fields } = useFieldArray({     name: \"users\",     control: control,     shouldUnregister: true   })    const onSave = (data) => {     console.log(data)   }    useEffect(() => {     const getUsersAsync = async () => {       const { data } = await axios.get(\"http:\/\/localhost:3000\/users\")       reset({         users: data       })     }     getUsersAsync()   }, [reset])    return (     &lt;FormProvider {...methods}>       {fields.map((user, index) => (         &lt;UserCard key={user.id} user={user} userIndex={index} \/>       ))}       &lt;Button onClick={handleSubmit(onSave)}>\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c&lt;\/Button>     &lt;\/FormProvider>   ); } <\/code><\/pre>\n<ol>\n<li>\n<p>\u0412 \u0445\u0443\u043a\u0435 useForm \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0443 \u043d\u0430\u0441 \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0445\u0443\u043a useFieldArray ( fields ).  <\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 API \u0438 \u043f\u0435\u0440\u0435\u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0432\u0430\u0435\u043c \u043d\u0430\u0448\u0443 \u0444\u043e\u0440\u043c\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 reset.<\/p>\n<\/li>\n<li>\n<p>\u0418, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0438\u0441\u0430\u043b\u0438\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043d\u0430\u0448\u0435\u0433\u043e API.  <\/p>\n<\/li>\n<\/ol>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u043e\u0434 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0438.<\/p>\n<pre><code class=\"javascript\">import { TextField } from \"@mui\/material\" import { Controller, useFormContext } from \"react-hook-form\" import \".\/App.css\"  export const UserCard = (props) => {     const { user: { name, suname }, userIndex } = props     const { control } = useFormContext()      return (         &lt;div className=\"card\">             &lt;div className=\"card__header\">                 &lt;span>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c {userIndex + 1}&lt;\/span>             &lt;\/div>             &lt;Controller                 name={`users[${userIndex}].name`}                 control={control}                 defaultValue={name}                 render={({ field: { value, onChange } }) => (                     &lt;TextField                         value={value}                         onChange={onChange}                     \/>                 )}             \/>             &lt;Controller                 name={`users[${userIndex}].suname`}                 control={control}                 defaultValue={suname}                 render={({ field: { value, onChange } }) => (                     &lt;TextField                         value={value}                         onChange={onChange}                     \/>                 )}             \/>       &lt;\/div>     ) }<\/code><\/pre>\n<ol>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432 Controller \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f defaultValue \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0438\u0437 props.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f \u0442\u0430\u043a\u0436\u0435 name \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044f. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 users &#8212; \u044d\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432, \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043a\u0430\u0445, \u0430 \u0437\u0430\u0442\u0435\u043c name \u0438 surname. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0439\u0442\u0438 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442.<\/p>\n<\/li>\n<\/ol>\n<h2>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u043a\u0430\u0440\u0442\u043e\u0447\u0435\u043a<\/h2>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u043d\u0430\u0448\u0435\u0439 \u0444\u043e\u0440\u043c\u044b &#8212; \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0442\u0435\u043c \u0436\u0435 useFieldArray, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u0438\u043c\u043e fields \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e append \u0438 remove. \u0412\u043e\u0442 \u043a\u0430\u043a \u044f \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b.  <\/p>\n<pre><code class=\"javascript\">import { useEffect } from \"react\" import { Button } from \"@mui\/material\"; import { FormProvider, useFieldArray, useForm } from \"react-hook-form\"; import { UserCard } from \".\/UserCard\"; import axios from \"axios\";  export const App = () => {   const methods = useForm({     defaultValues: {       users: []     }   })    const { control, handleSubmit, reset } = methods    const { append, remove, fields } = useFieldArray({     name: \"users\",     control: control   })    const onSave = (data) => {     console.log(data)   }    const onAddUser = () => {     const lastUser = fields.at(-1)     let newUserId = 1;      if (lastUser) {       newUserId = lastUser.id + 1;     }          append({       id: newUserId,       name: \"\",       suname: \"\"     })   }    const onDeleteUser = (userIndex) => {     remove(userIndex)   }    useEffect(() => {     const getUsersAsync = async () => {       const { data } = await axios.get(\"http:\/\/localhost:3000\/users\")       reset({         users: data       })     }     getUsersAsync()   }, [reset])    return (     &lt;FormProvider {...methods}>       {fields?.map((user, index) => (         &lt;UserCard key={index} user={user} userIndex={index} onDeleteUser={onDeleteUser} \/>       ))}       &lt;Button onClick={onAddUser}>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f&lt;\/Button>       &lt;Button onClick={handleSubmit(onSave)}>\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c&lt;\/Button>     &lt;\/FormProvider>   ); } <\/code><\/pre>\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 id. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 id \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0434\u0438\u043d\u0438\u0446\u0443. \u0421\u0442\u043e\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0432 \u0445\u0443\u043a\u0435 useFieldArray \u0431\u044b\u043b\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u043f\u043e\u043b\u0435 keyName \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c key. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e useFieldArray \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0435 id, \u043d\u043e \u0442\u0430\u043a \u043a\u0430\u043a \u0443 \u043d\u0430\u0441 id \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0441 API, \u0430 \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435, \u044d\u0442\u043e\u0442 \u043a\u043b\u044e\u0447 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u0438\u043d\u0430\u0447\u0435, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u043e\u0432.  <\/p>\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 remove, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0438\u043d\u0434\u0435\u043a\u0441 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c. \u0418\u043d\u0434\u0435\u043a\u0441 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0438 \u0432 props.  <\/p>\n<p>\u0418, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f UserCard.<\/p>\n<pre><code class=\"javascript\">import { Button, TextField } from<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-349988","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/349988","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=349988"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/349988\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=349988"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=349988"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=349988"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}