Skip to content

Commit

Permalink
fix(schema-renderer): Fix expression complie perf bug (#986)
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang authored Aug 3, 2020
1 parent 74fa86c commit 0e8383e
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
78 changes: 78 additions & 0 deletions docs/zh-cn/schema-develop/faq.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
```jsx
import React from 'react'
import ReactDOM from 'react-dom'
import {
SchemaForm,
Field,
FormButtonGroup,
Submit,
Reset,
Balloon,
Icon
} from '@formily/next'
import {
Input,
ArrayTable,
DatePicker,
FormBlock,
FormItemGrid,
FormLayout
} from '@formily/next-components'
import '@alifd/next/dist/next.css'
import Printer from '@formily/printer'

const App = () => (
<Printer>
<SchemaForm
components={{
ArrayTable,
Input,
RangePicker: DatePicker.RangePicker
}}
>
<FormLayout>
<Field
title="数组"
name="array"
maxItems={30}
type="array"
x-component="ArrayTable"
x-component-props={{
renderExtraOperations() {
return <div>Hello worldasdasdasdasd</div>
},
operationsWidth: 300
}}
>
<Field type="object">
<Field
name="aa"
x-component="Input"
description="hello world"
title={
<div style={{ display: 'inline-block' }}>
<span>字段1</span>
<span>字段1</span>
<span>字段1</span>
<span>字段1</span>
</div>
}
/>
<Field
key={0}
name="bb"
x-component="Input"
title={() => {
return <div>字段2</div>
}}
/>
<Field key={1} name="cc" x-component="Input" title={'字段3'} />
<Field key={3} name="ee" x-component="Input" title={'字段5'} />
</Field>
</Field>
</FormLayout>
</SchemaForm>
</Printer>
)
ReactDOM.render(<App />, document.getElementById('root'))
```
3 changes: 3 additions & 0 deletions packages/react-schema-renderer/src/shared/expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export const complieExpression = <Source = any, Context = any>(
} else if (isArr(source)) {
return source.map(value => complie(value))
} else if (isPlainObj(source)) {
if('$$typeof' in source && '_owner' in source){
return source
}
if (source[actionsSymbol]) {
return source
}
Expand Down

0 comments on commit 0e8383e

Please sign in to comment.