/* eslint-disable */ import React, { useState, useLayoutEffect, Component, useEffect } from 'react'; import { storiesOf } from '@storybook/react'; import { Button, Modal, TreeSelect, Row, Col, Avatar, TextArea, Input as BasicInput, Select as BasicSelect, Form, useFormState, useFormApi, useFieldApi, useFieldState, withFormState, withFormApi, withField, ArrayField, AutoComplete, Collapse, Icon } from '../../../index'; import { ComponentUsingFormState } from '../Hook/hookDemo'; const { Input, Select, DatePicker, Switch, Slider, CheckboxGroup, Checkbox, RadioGroup, Radio, TimePicker, InputNumber, InputGroup } = Form; class Test extends React.Component { constructor() { super(); console.log(this.props); debugger; } componentWillReceiveProps(prevProps) { console.log(this.props); debugger; } componentDidMount() { console.log(this.props); debugger; } componentWillUnmount() { console.log(this.props); debugger; } render() { return this.props.value; } } const FCC = (() => () => { useEffect(() => { // effect debugger; return () => { debugger; }; }, []); return
t
; })(); class SetValuesArray extends React.Component { constructor() { super(); this.state = { initValues: { effects: [ { name: 'A', key: '12312' }, { name: 'B', key: '234234' }, { name: 'C', key: '345435' }, ] } }; this.id = 3; this.getFormApi = this.getFormApi.bind(this); this.add = this.add.bind(this); this.remove = this.remove.bind(this); this.renderItems = this.renderItems.bind(this); const iii = Form.Input; } getFormApi(formApi) { this.formApi = formApi; } add(obj) { let effects = this.formApi.getValue('effects'); if (!effects) { effects = []; } effects.push({ name: '', type: '', key: Math.random() }); // effects.push({ name: '', type: '', key: this.id++ }); // this.formApi.setValue('effects', effects); this.formApi.setValues({ ...this.formApi.getValue(), effects }, { isOverride: true }); } remove(key) { let effects = this.formApi.getValue('effects'); effects = effects.filter((effect, index) => key !== effect.key); if (!effects.length) { effects = undefined; } // this.formApi.setValue('effects', effects); this.formApi.setValues({ ...this.formApi.getValue(), effects }, { isOverride: true }); } renderItems(formState, values) { console.log(values); return values.effects && values.effects.map((effect, i) => ( //
{/* */} {/* */} {/* */} {/* */} {/* */} {effect.key}
)); } render() { let { initValues } = this.state; return ( <>
{({ formState, values }) => ( <> {this.renderItems(formState, values)}