小编Jos*_*own的帖子

React hooks:“类型错误:对象不是函数”

我使用的是 React 版本 16.13.1。

我收到“类型错误:对象不是函数”

这是我的代码(错误消息似乎认为第 7 行有问题):

import React, { useState } from 'react';
import fb from '../config/firebase';
import ProcessInput from './customHooks/processInput';

const DashBoard = ({ level, newUser }) => {

  const [val, bind] = ProcessInput('');

  const handleChange = (e) => {
    e.preventDefault();
  }
Run Code Online (Sandbox Code Playgroud)

这是我的自定义钩子:

import { useState } from 'react';

export const ProcessInput = value => {
  const [val, setVal] = useState(value);

  return {
    val,
    setVal,
    bind: {
      val,
      onChange: event => {
        setVal(event.target.value);
      }
    }
  };
}; …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-hooks

0
推荐指数
1
解决办法
6003
查看次数

标签 统计

javascript ×1

react-hooks ×1

reactjs ×1