我正在努力完成一本“反应教程”。有一次,作者向我展示了如何构建一个简单的表单,它工作得很好。然后,他继续将它升级为“React”。
每件事都按照说明进行,直到最后一行,他说了下面的话。
“向Header组件的JSX中的输入元素添加一个ref属性,并将其设置为register表单中的寄存器函数:”
就在这个时候,我遇到了以下错误。
Type 'UseFormRegister<FormData>' is not assignable to type 'LegacyRef<HTMLInputElement> | undefined'.
Ty
我是一个初学者使用(我已经使用了一段时间了),我正在尝试在我的事件处理程序中使用自定义钩子。
但是,我收到这样的错误:
React Hook "useMyCustomHook" is called in function "onSubmit" which is neither a React function component or a custom React Hook function react-hooks/rules-of-hooks
这是我的代码:
import MyCustomHook from './myCustomHook';
谁能告诉我,在我的主页组件上单击提交后,如何清除所有输入?我试着在subjectForm组件中使用了reset()方法,但是我不是用错了就是不起作用。我还尝试使用setState,并将我的输入恢复为默认状态,该状态为空,但同样不起作用。
我的代码中的所有内容都运行良好,但是每次我提交一个主题时,字段都不会自动清除
这是我的主页组件。
import React from 'react';
import SubjectForm from './SubjectForm';
import {addSubject} from '../act
我对Redux不熟悉。理解基本语法真是令人费解。没有发现任何bug,所以很难找出我的代码有什么问题。
上周效果很好,我不记得我改变了什么。
//儿童部分
import React, { Component } from 'react';
import { SingleDatePicker } from 'react-dates';
import moment from 'moment';
class InputForms extends Component {
state = {
inputs: ['input-0'
下面是我尝试使用的示例代码,即react + TypeScript。onDragEnter和onDragOver工作正常,但onDrop事件不正常。
import * as React from 'react';
export class FileZone extends React.Component {
onDragOver = (e) => {
let event = e as Event;
event.stopPropagation();
}
onDragEnter = (e) => {
let event = e