Javascript 无法使用React挂钩呈现功能组件

Javascript 无法使用React挂钩呈现功能组件,javascript,reactjs,react-hooks,Javascript,Reactjs,React Hooks,我是新手。我正在尝试使用以下组件作为ReactTable组件中一列的过滤器输入元素 import React,{useState}来自“React” 从“物料ui/DatePicker/DatePickerDialog”导入日期选择器 导入“../style/style.less” 导出默认函数DateRange({StartAbel='From',endLabel='到'}={}){ const[open,setOpen]=useState(false) 返回( setOpen(true)}/

我是新手。我正在尝试使用以下组件作为ReactTable组件中一列的过滤器输入元素

import React,{useState}来自“React”
从“物料ui/DatePicker/DatePickerDialog”导入日期选择器
导入“../style/style.less”
导出默认函数DateRange({StartAbel='From',endLabel='到'}={}){
const[open,setOpen]=useState(false)
返回(
setOpen(true)}/>
)
}
但渲染失败,出现以下错误:

Uncaught Invariant Violation: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app

这看起来不错。您的代码中一定有其他未显示的内容。您如何调用
DateRange
?@brianthonpson感谢您指出这一点。我正在调用
DateRange()
,在我将其更改为