-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(react): fix formSpy conflict with parent SchemaForm (#854)
- Loading branch information
Showing
3 changed files
with
8 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +0,0 @@ | ||
# FAQ | ||
|
||
```jsx | ||
import React, { useEffect, useState } from 'react' | ||
import ReactDOM from 'react-dom' | ||
import { SchemaForm } from '@formily/antd' // 或者 @formily/next | ||
import { Input, Select, Radio } from '@formily/antd-components' | ||
import Printer from '@formily/printer' | ||
import 'antd/dist/antd.css' | ||
|
||
const mockSchema = { | ||
type: 'object', | ||
properties: { | ||
aa: { | ||
type: 'boolean', | ||
enum: [ | ||
{ label: '设置bb的枚举列表', value: true }, | ||
{ label: '还原bb的枚举列表', value: false } | ||
], | ||
default: false, | ||
title: 'AA', | ||
'x-component': 'RadioGroup', | ||
'x-linkages': [ | ||
{ | ||
type: 'value:schema', | ||
target: 'bb', | ||
condition: '{{!!$value}}', | ||
schema: { | ||
enum: ['xx1', 'xx2', 'xx3'] | ||
}, | ||
otherwise: { | ||
enum: ['zz'] | ||
} | ||
} | ||
] | ||
}, | ||
bb: { | ||
type: 'string', | ||
title: 'BB', | ||
'x-component': 'Input', | ||
enum: ['yy'] | ||
}, | ||
cc: { | ||
type: 'string', | ||
title: '{{customCCTitle}}', | ||
'x-component': 'Input' | ||
} | ||
} | ||
} | ||
|
||
const App = () => { | ||
const [schema, setSchema] = useState({ | ||
type: 'object' | ||
}) | ||
useEffect(() => { | ||
setTimeout(() => { | ||
setSchema(mockSchema) | ||
}, 1000) | ||
}, []) | ||
|
||
return ( | ||
<Printer> | ||
<SchemaForm | ||
schema={schema} | ||
components={{ Input, Select, RadioGroup: Radio.Group }} | ||
onSubmit={values => { | ||
console.log(values) | ||
}} | ||
expressionScope={{ | ||
customTitle: 'this is custom title', | ||
customCCTitle: 'CC' | ||
}} | ||
/> | ||
</Printer> | ||
) | ||
} | ||
|
||
ReactDOM.render(<App />, document.getElementById('root')) | ||
``` | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters