react-hoook-form
react-hook-form ライブラリを使用時に下記のようなエラーがでたので、その解決方法を記述する
TypeError: path split is not a function
原因
react-hook-form 6と7のバージョン違いによる書き方の違いらしい?↓
react-hook-form updated to 7.0.0 from 6.X.X and has breaking changes:
You have to replace all ref={register} with {...register('value_name')}
具体例
バージョン
"react-hook-form": "^7.22.5",
エラーバージョン
<div className={styles.root}>
<form onSubmit={handleSubmit(handleCreate)} className={styles.form}>
<TextField
id="outlined-basic"
label="New Task"
variant="outlined"
inputRef={register} //←エラー
name="taskTitle"
className={styles.text_field}
/>
</form>
</div>
変更後
<div className={styles.root}>
<form onSubmit={handleSubmit(handleCreate)} className={styles.form}>
<TextField
id="outlined-basic"
label="New Task"
variant="outlined"
{...register('taskTitle')} //変更後
name="taskTitle"
className={styles.text_field}
/>
</form>
</div>