Skip to content

Commit fd0f64b

Browse files
ffxingyuefeng
authored andcommitted
docs: 优化ExpandableSection组件
1 parent ffb08e9 commit fd0f64b

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed

packages/core/src/ExpandableSection/README.md

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,43 @@ ExpandableSection 展开缩放
33

44
ExpandableSection 组件以在 sectionHeader标题 下方或上方呈现展开的内容部分
55

6-
![](https://user-images.githubusercontent.com/66067296/137708253-1b6c2dfb-9c89-477a-a6ea-0c46120bf86d.gif)<!--rehype:style=zoom: 33%;float: right; margin-left: 15px;-->
7-
86
### 基础示例
97

10-
<!--DemoStart-->
11-
```js
12-
import React from 'react';
13-
import { ExpandableSection,H5 } from '@uiw/react-native';
14-
15-
export default class ExpandableSectionDemo extends Component {
16-
state={
17-
expanded:false,
18-
top:false
19-
}
20-
render() {
21-
return (
22-
<ExpandableSection
23-
expanded={this.state.expanded}
24-
onPress={() => this.setState({ expanded: !this.state.expanded })}
25-
sectionHeader={<H5>我是标题</H5>}
26-
top={this.state.top}
27-
>
28-
<View>
29-
<Text style={{ color: 'red' }}>展开的内容</Text>
30-
</View>
8+
```jsx mdx:preview
9+
import React, {useState} from 'react';
10+
import { ExpandableSection } from '@uiw/react-native';
11+
import { View, Text } from 'react-native'
12+
13+
const Demo = () => {
14+
const [state, setState] = useState({
15+
expanded: false,
16+
top: false
17+
})
18+
19+
return (
20+
<View style={{height: 100}}>
21+
<ExpandableSection
22+
expanded={state.expanded}
23+
onPress={() => setState({...state, expanded: !state.expanded })}
24+
sectionHeader={<Text >点击我</Text>}
25+
top={state.top}
26+
>
27+
<Text style={{ color: 'red' }}>
28+
有一天路标迁了希望你能从容
29+
30+
有一天桥墩断了希望你能渡越
31+
32+
有一天栋梁倒了希望你能坚强
33+
34+
有一天期待蔫了希望你能理解
35+
</Text>
3136
</ExpandableSection>
32-
)
33-
}
37+
</View>
38+
)
3439
}
40+
41+
export default Demo
3542
```
36-
<!--End-->
3743

3844
### Props
3945

0 commit comments

Comments
 (0)