UNPKG

@antdp/edit-table

Version:

基于antd封装的组件

30 lines 669 B
import React from "react"; class Store { constructor() { this.store = {}; /** 移除 */ this.remove = name => { delete this.store["" + name]; }; /** 注册 */ this.register = (name, form) => { this.store["" + name] = form; }; /** 获取所有的 from 保存值 */ this.getStore = () => this.store; /** 通过 key 获取 form 表单 */ this.getToKeyForm = key => { return this.store["" + key]; }; } } export var useStore = store => { var refs = React.useRef(); if (store) { refs.current = store; } else { refs.current = new Store(); } return [refs.current]; }; export default Store;