From 7f3004c4c5186c845b196fdb3b767b12224fe3a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E6=96=87=E9=9B=84?= Date: Thu, 31 Oct 2019 18:11:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20schemaForm=20props.value=20=E5=8F=98?= =?UTF-8?q?=E5=8C=96=E4=BA=86,=20jsf=20=E6=B2=A1=E6=9C=89=E5=A4=84?= =?UTF-8?q?=E7=90=86=E7=9A=84=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/{widgets/input => common}/watchProps.js | 0 src/index.js | 14 ++++++++++++++ src/widgets/input/index.js | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) rename src/{widgets/input => common}/watchProps.js (100%) diff --git a/src/widgets/input/watchProps.js b/src/common/watchProps.js similarity index 100% rename from src/widgets/input/watchProps.js rename to src/common/watchProps.js diff --git a/src/index.js b/src/index.js index ccb2e81..eacd5c2 100644 --- a/src/index.js +++ b/src/index.js @@ -7,6 +7,8 @@ import ArraySchemaForm from './array-schema-form' import {Button} from 'antd' import './index.scss' import getName from './locale' +import watchProps from './common/watchProps' + const Ajv = require('ajv'); const ajv = new Ajv(); @@ -31,6 +33,7 @@ function setData(state, keys, value) { } +@watchProps export default class JsonSchemaForm extends React.PureComponent { constructor (props) { super (props); @@ -63,6 +66,17 @@ export default class JsonSchemaForm extends React.PureComponent { locale: 'en_US' }; + watch = { + value: { + deep: false, + hander(v){ + this.changeStore(store=>{ + store.value = v + }) + } + } + } + moveArrayItem =(paths, from, to)=>{ function arrMove(arr, fromIndex, toIndex) { diff --git a/src/widgets/input/index.js b/src/widgets/input/index.js index d25dd11..4cfa527 100644 --- a/src/widgets/input/index.js +++ b/src/widgets/input/index.js @@ -1,7 +1,7 @@ import {Input} from 'antd'; import React, {Component} from 'react'; import PropTypes from 'prop-types'; -import watchProps from './watchProps'; +import watchProps from '../../common/watchProps'; @watchProps export default class InputBlurSearchComponent extends Component {