1
1
export const example1 = `import React, { Component } from 'react'
2
2
import EdiText from 'react-editext'
3
3
4
- export default class App extends Component {
5
- onSave = val => {
4
+ export default function App() {
5
+ function onSave( val) {
6
6
console.log('Edited Value -> ', val)
7
7
}
8
8
9
- render () {
10
- return (
11
- <EdiText
12
- type='text'
13
- value='What is real? How do you define real?'
14
- onSave={this.onSave}
15
- />
16
- )
17
- }
9
+ return (
10
+ <EdiText
11
+ type='text'
12
+ value='What is real? How do you define real?'
13
+ onSave={this.onSave}
14
+ />
15
+ )
18
16
}
19
17
`
20
18
export const example2 = `<EdiText
@@ -50,29 +48,27 @@ export const example4 = `<EdiText
50
48
onSave={this.onSave}
51
49
/>`
52
50
53
- export const example5 = `export default class App extends Component {
54
- onSave = val => {
51
+ export const example5 = `export default function App() {
52
+ function onSave( val) {
55
53
console.log('Edited Value -> ', val)
56
54
}
57
55
58
- validationFailed = textValue => {
56
+ function validationFailed( textValue) {
59
57
alert(\`The text <\${textValue}> is not valid.\nYou shall not use the word SMITH here!!!\`)
60
58
}
61
59
62
- render () {
63
- return (
64
- <EdiText
65
- type="text"
66
- validation={val => val.toLowerCase().indexOf('smith') < 0}
67
- onValidationFail={this.validationFailed}
68
- inputProps={{
69
- placeholder: "Don't use the word 'Smith'..."
70
- }}
71
- value="Why Mr. Anderson? Why? Why? Why?"
72
- onSave={this.onSave}
73
- />
74
- )
75
- }
60
+ return (
61
+ <EdiText
62
+ type="text"
63
+ validation={val => val.toLowerCase().indexOf('smith') < 0}
64
+ onValidationFail={this.validationFailed}
65
+ inputProps={{
66
+ placeholder: "Don't use the word 'Smith'..."
67
+ }}
68
+ value="Why Mr. Anderson? Why? Why? Why?"
69
+ onSave={this.onSave}
70
+ />
71
+ )
76
72
}`
77
73
78
74
export const example6 = `<EdiText
@@ -173,28 +169,26 @@ export const example12 = `<EdiText
173
169
export const example13 = `import React, { Component } from 'react'
174
170
import EdiText from 'react-editext'
175
171
176
- export default class App extends Component {
177
- onSave = val => {
172
+ export default function App() {
173
+ function onSave( val) {
178
174
console.log('Edited Value -> ', val)
179
175
}
180
176
181
- render () {
182
- return (
183
- <EdiText
184
- viewContainerClassName='my-custom-view-wrapper'
185
- type='textarea'
186
- inputProps={{
187
- rows: 5
188
- }}
189
- saveButtonContent='Apply'
190
- cancelButtonContent={<strong>Cancel</strong>}
191
- editButtonContent='Edit This Quote'
192
- value="How do you define real? If you're talking about what you can feel, what you can smell,
193
- what you can taste and see, then real is simply electrical signals interpreted by your brain"
194
- onSave={this.onSave}
195
- />
196
- )
197
- }
177
+ return (
178
+ <EdiText
179
+ viewContainerClassName='my-custom-view-wrapper'
180
+ type='textarea'
181
+ inputProps={{
182
+ rows: 5
183
+ }}
184
+ saveButtonContent='Apply'
185
+ cancelButtonContent={<strong>Cancel</strong>}
186
+ editButtonContent='Edit This Quote'
187
+ value="How do you define real? If you're talking about what you can feel, what you can smell,
188
+ what you can taste and see, then real is simply electrical signals interpreted by your brain"
189
+ onSave={this.onSave}
190
+ />
191
+ )
198
192
}`
199
193
200
194
export const example13Style = `
@@ -214,41 +208,37 @@ export const example13Style = `
214
208
export const example14 = `import React, { Component } from 'react'
215
209
import EdiText from 'react-editext'
216
210
217
- export default class App extends Component {
218
- onSave = val => {
211
+ export default function App() {
212
+ function onSave( val) {
219
213
console.log('Edited Value -> ', val)
220
214
}
221
215
222
- render () {
223
- return (
224
- <EdiText
225
- type='text'
226
- buttonsAlign='before'
227
- value='What is real? How do you define real?'
228
- onSave={this.onSave}
229
- />
230
- )
231
- }
216
+ return (
217
+ <EdiText
218
+ type='text'
219
+ buttonsAlign='before'
220
+ value='What is real? How do you define real?'
221
+ onSave={this.onSave}
222
+ />
223
+ )
232
224
}
233
225
`
234
226
export const example15 = `import React, { Component } from 'react'
235
227
import EdiText from 'react-editext'
236
228
237
- export default class App extends Component {
238
- onSave = val => {
229
+ export default function App() {
230
+ function onSave( val) {
239
231
console.log('Edited Value -> ', val)
240
232
}
241
233
242
- render () {
243
- return (
244
- <EdiText
245
- type='text'
246
- value='What is real? How do you define real?'
247
- onSave={this.onSave}
248
- editOnViewClick={true}
249
- />
250
- )
251
- }
234
+ return (
235
+ <EdiText
236
+ type='text'
237
+ value='What is real? How do you define real?'
238
+ onSave={this.onSave}
239
+ editOnViewClick={true}
240
+ />
241
+ )
252
242
}`
253
243
254
244
export const example16 = `import React, { Component } from 'react'
@@ -258,7 +248,7 @@ export default function App() {
258
248
const [editing, setEditing] = useState(false)
259
249
const [data, setData] = useState({ name: 'Wake up, Neo...' })
260
250
261
- const onSave = val => {
251
+ function onSave( val) {
262
252
console.log('Edited Value -> ', val)
263
253
}
264
254
@@ -291,19 +281,17 @@ export default function App() {
291
281
export const example17 = `import React, { Component } from 'react'
292
282
import EdiText from 'react-editext'
293
283
294
- export default class App extends Component {
284
+ export default function App() {
295
285
296
- render () {
297
- return (
298
- <EdiText
299
- type='text'
300
- onCancel={v => console.log('CANCELLED: ', v}
301
- onEditingStart={v => console.log('EDITING STARTED: ', v}
302
- onSave={v => console.log('SAVED: ', v}
303
- value={"You've been living in a dream world, Neo."}
304
- />
305
- )
306
- }
286
+ return (
287
+ <EdiText
288
+ type='text'
289
+ onCancel={v => console.log('CANCELLED: ', v}
290
+ onEditingStart={v => console.log('EDITING STARTED: ', v}
291
+ onSave={v => console.log('SAVED: ', v}
292
+ value={"You've been living in a dream world, Neo."}
293
+ />
294
+ )
307
295
}`
308
296
309
297
export const example18 = `<EdiText
0 commit comments