2
2
[ ![ Gitter] ( https://badges.gitter.im/Join%20Chat.svg )] ( https://gitter.im/cht8687/help )
3
3
4
4
<big ><h1 align =" center " >React expandable listview</h1 ></big >
5
+ <h2 align =" center " >Rend components or plain object in an expandable way!</h2 >
5
6
6
7
<p align =" center " >
7
8
<a href =" https://circleci.com/gh/cht8687/react-expandable-listview " >
@@ -83,11 +84,16 @@ The component accepts three props.
83
84
84
85
#### ` data ` : PropTypes.array.isRequired
85
86
87
+ * note that ` isReactComponent ` is used to select if you want to render a react object or not.
88
+
89
+ ### Render plain object
90
+
86
91
``` js
87
92
const DATALIST = [
88
93
{
89
94
headerName : " ListG" ,
90
95
isOpened: true ,
96
+ isReactComponent: false ,
91
97
items : [{
92
98
title : " items1"
93
99
}, {
@@ -105,6 +111,7 @@ const DATALIST = [
105
111
},{
106
112
headerName : " ListH" ,
107
113
isOpened: true ,
114
+ isReactComponent: false ,
108
115
items : [{
109
116
title : " items1"
110
117
}, {
@@ -117,6 +124,102 @@ const DATALIST = [
117
124
];
118
125
```
119
126
127
+ ### Render react component
128
+
129
+ If you want to render a react component, for example, a menu object, you can set ` isReactComponent ` to ` true ` :
130
+
131
+ ``` js
132
+ export default class Menu extends React .Component {
133
+ static get menuItems () {
134
+ return [
135
+ {
136
+ headerName: ' Products' ,
137
+ isOpened: false ,
138
+ height: 100 ,
139
+ isReactComponent: true ,
140
+ items: [
141
+ (
142
+ < Link
143
+ to= " admin/products/all"
144
+ className= " btn btn-default"
145
+ activeClassName= " active"
146
+ >
147
+ All
148
+ < / Link>
149
+ ),
150
+ (
151
+ < Link
152
+ to= " admin/products/expired"
153
+ className= " btn btn-default"
154
+ activeClassName= " active"
155
+ >
156
+ Expired
157
+ < / Link>
158
+ ),
159
+ (
160
+ < Link
161
+ to= " admin/products/submitted"
162
+ className= " btn btn-default"
163
+ activeClassName= " active"
164
+ >
165
+ Submitted
166
+ < / Link>
167
+ ),
168
+ ],
169
+ },
170
+ {
171
+ headerName: ' Promotions' ,
172
+ isOpened: false ,
173
+ height: 100 ,
174
+ isReactComponent: true ,
175
+ items: [
176
+ (
177
+ < Link
178
+ to= " admin/promotions/active"
179
+ className= " btn btn-default"
180
+ activeClassName= " active"
181
+ >
182
+ Active
183
+ < / Link>
184
+ ),
185
+ ],
186
+ },
187
+ {
188
+ headerName: ' Settings' ,
189
+ isOpened: false ,
190
+ height: 100 ,
191
+ isReactComponent: true ,
192
+ items: [
193
+ (
194
+ < Link
195
+ to= " admin/settings/all"
196
+ className= " btn btn-default"
197
+ activeClassName= " active"
198
+ >
199
+ Al
200
+ < / Link>
201
+ ),
202
+ ],
203
+ },
204
+ ];
205
+ }
206
+
207
+ render () {
208
+ return (
209
+ < div id= " admin-menu" >
210
+ < ReactExpandableListView
211
+ data= {this .constructor .menuItems }
212
+ headerAttName= " headerName"
213
+ itemsAttName= " items"
214
+ / >
215
+ < / div>
216
+ );
217
+ }
218
+ }
219
+
220
+ ```
221
+
222
+
120
223
Note ` height ` varible defines the height you want each list to be like.
121
224
You can set different height data to suit the content of each section.
122
225
0 commit comments