Socket
Book a DemoInstallSign in
Socket

@lovelope/create-factory

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lovelope/create-factory

Lightweight higher order components for edit page or detail page.

0.1.2
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

@lovelope/create-factory

CreateFactory is a high-level component used to manage editing pages and details pages; it is mainly responsible for data pulling and updating.

English 中文

安装

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

使用

import CreateFactory from '@lovelope/create-factory';
import React from 'react';
import { Form } from 'antd';
import { getUserInfo, putUserInfo } from './services';

const FormItem = Form.Item;

// this page's path is /user/edit/:userId

@CreateFactory({
  key: 'userId',
  getAction: getUserInfo,
  putAction: putUserInfo,
})
class Email extends React.Component {
  render() {
    const {
      form: { getFieldDecorator },
    } = this.props;
    return (
      <Form>
        <FormItem label="username">
          {getFieldDecorator('name')(<Input />)}
        </FormItem>
        <FormItem label="Eamil">
          {getFieldDecorator('email')(<Input />)}
        </FormItem>
      </Form>
    );
  }
}

Options

PropertyDescriptiontyperequireddefault
keyID value defined in routing URLstring, numberfalse'id'
getActionThe function that pulls the form data when it is initialized() => promisefalse--
putActionSubmit the function to be called after editing the form() => promisefalse--
postActionThe function to be called when adding a new formpromisefalse--
mapPropsToFieldsThe formatting function of the data that getAction is filled in before the form item is filled in.functionfalse() => {}
initialValuesForm default valuesobjectfalse{}

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.