2.0.17 • Published 6 months ago

mobx-react-hook-form v2.0.17

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

mobx-react-hook-form

Simple react-hook-form wrapper for MobX.

Usage

import { reaction } from "mobx"
import { MobxForm } from "mobx-react-hook-form"

class YourVM { 
  form = new MobxForm({
    disposer?: this.disposer,
    resolver: valibotResolver(
      v.object({
        username: v.string('This field is required')
      })
    ),
    onSubmit: ({ username }) => {
      console.info("nick username", username);
    },
    onSubmitFailed: () => {
      //
    },
    onReset: () => {
      //
    }
  })

  mount(){
    reaction(
      () => this.form.data?.username,
      (username) => {
        //
      }
    )
  }
}


const YourView = () => {
  const form = useMobxForm(yourVM.form)


  return (
    <form onSubmit={form.onSubmit} onReset={form.onReset}>
      <Controller control={form.control} name={'username'} render={...} />
    </form>
  )
}
1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago

1.0.9

10 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

2.0.15

6 months ago

2.0.3

10 months ago

2.0.16

6 months ago

2.0.2

10 months ago

2.0.13

6 months ago

2.0.5

10 months ago

2.0.14

6 months ago

2.0.4

10 months ago

2.0.11

6 months ago

2.0.7

6 months ago

2.0.12

6 months ago

2.0.6

8 months ago

2.0.9

6 months ago

2.0.10

6 months ago

2.0.8

6 months ago

2.0.1

10 months ago

2.0.0

10 months ago

2.0.17

6 months ago

1.0.11

10 months ago

1.0.10

10 months ago

1.0.13

10 months ago

1.0.12

10 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago