-
Notifications
You must be signed in to change notification settings - Fork 90
/
index.jsx
54 lines (48 loc) · 1.33 KB
/
index.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import InlineEdit from '../index';
import React from 'react';
import ReactDOM from 'react-dom';
class MyParentComponent extends React.Component {
constructor(props){
super(props);
this.dataChanged = this.dataChanged.bind(this);
this.state = {
message: 'ReactInline demo'
}
}
dataChanged(data) {
// data = { description: "New validated text comes here" }
// Update your model from here
console.log(data)
this.setState({...data})
}
customValidateText(text) {
return (text.length > 0 && text.length < 64);
}
render() {
return (<div>
<h2>{this.state.message}</h2>
<span>Edit me: </span>
<InlineEdit
validate={this.customValidateText}
activeClassName="editing"
text={this.state.message}
paramName="message"
change={this.dataChanged}
style={{
backgroundColor: 'yellow',
minWidth: 150,
display: 'inline-block',
margin: 0,
padding: 0,
fontSize: 15,
outline: 0,
border: 0
}}
/>
</div>)
}
}
ReactDOM.render(
<MyParentComponent />,
document.getElementById('app')
);