-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathapp.tsx
42 lines (34 loc) · 1019 Bytes
/
app.tsx
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
import * as React from 'react';
import { HelloComponent } from './hello';
import { NameEditComponent } from './nameEdit';
interface Props {
}
interface State {
userName: string;
editingUserName: string;
}
export class App extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
const defaultUserName = 'defaultUserName';
this.state = { userName: defaultUserName, editingUserName: defaultUserName };
}
setUsernameState = () => {
this.setState({ userName: this.state.editingUserName });
}
updateEditingName = (editingName: string): void => {
this.setState({ editingUserName: editingName });
}
public render() {
return (
<>
<HelloComponent userName={this.state.userName} />
<NameEditComponent
userName={this.state.userName}
editingUserName={this.state.editingUserName}
onEditingNameUpdated={this.updateEditingName}
onNameUpdateRequest={this.setUsernameState} />
</>
);
}
}