react class改hooks写法

类头修改

export default class EditUseTable extends Component 

改为

export default function EditUseTable({})

参数修改

constructor(props) {
    super(props)
    const {
      dbRecord, type, currentRecord, readOnly, updateTaxAmount
    } = this.props

改为(主函数的参数)

export default function EditUseTable({
  dbRecord, type, currentRecord, readOnly, updateTaxAmount
  })

状态修改

this.state = {
      tableList: currentRecord?.bookList || [],
      visible: false,
      readOnly: readOnly,
      type: type,
      indexDbId: dbRecord.indexDbId,
      projectId: dbRecord.projectId,
      hasCostIndex: false,
    }

改为(不需要修改的状态直接去掉,直接用props参数就行)

    const [tableList,setTableList]=useState(currentRecord?.bookList || [])
    const [visible,setVisible]=useState(false)
    const [has

你可能感兴趣的:(react.js,javascript,前端)