Socket
Book a DemoInstallSign in
Socket

@lovelope/table-factory

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lovelope/table-factory

Combinable higher order components for list.

0.1.1
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

@lovelope/table-factory

TableFactory is a combinable higher order components for list management page, in order to fetch list data and manage filter queries.

English 中文

Install

npm i -S @lovelope/table-factory
# OR
yarn add -S @lovelope/table-factory

Usage

import TableFactory from '@lovelope/table-factory';
import React from 'react';
import { getGoodsList } from './services';

@TableFactory({
  getAction: getGoodsList,
  params: { pid },
  mute: ['searchWords'],
})
class GoodsList extends React.Component {
  render() {
    const {
      data: { list },
      query,
      loadData,
      onFilter,
      onReset,
    } = this.props;
    return (
      <div>
        <div className="header">
          <YourFilter onFilter={onFilter} query={query} onReset={onReset} />
        </div>
        <div className="body">
          <Table dataSource={list} />
        </div>
      </div>
    );
  }
}

Options

TableFactory

PropertyDescriptiontyperequireddefault
immediateUsed to control whether requests for data are sent immediately when filter conditions changebooleanfalsetrue
enumsModify the request parameter name of the page number section of the page with a set of objects (page, page Size by default)objectfalse{ page: 'page', pageSize: 'pageSize' }
muteControl request parameters that do not immediately send requests (such as keyword search, which may not be immediately searched if you want to enter)string[]false['keyword']
getActionRequest for table data() => Promise<object>true--
paramsAdditional Possible Parameters of getAction in addition to Screening Conditionsobjectfalse{}
formatData Processing Function of getAction before Initiating Requestfunctionfalsep => p

Tips

  • TableFactory injects data, query, onFilter, onReset and loadData five props into the component.
  • data is the data returned by getAction.
  • onFilter is a method of passing parameters to tableFactory. It receives two parameters. The first one is the parameter object, and the second one is the callback after reference.
  • onReset, if the page needs to reset all requests plus parameters, you can use this method;
  • loadData, an interface that actively calls table data;
  • query is the request parameter of getAction; you may need query to keep components under control.
  • If params sets additional request parameters, onReset will not empty these parameters, which is also helpful when the timeselector returns to some initial value.

Keywords

HOC

FAQs

Package last updated on 14 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.