-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathapp.tsx
More file actions
39 lines (31 loc) · 860 Bytes
/
app.tsx
File metadata and controls
39 lines (31 loc) · 860 Bytes
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
import * as React from 'react';
import { HelloComponent } from './hello';
import { NameEditComponent } from './nameEdit';
interface Props {
}
interface State {
userName: string;
changed: boolean;
}
export class App extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = { userName: 'defaultUserName', changed: false };
}
setUsernameState = (newName: string) => {
this.setState({userName: newName}, this.nameChanged);
}
nameChanged() {
this.setState({changed:true});
}
public render() {
return (
<>
<HelloComponent userName={this.state.userName} />
<NameEditComponent initialUserName={this.state.userName}
onNameUpdated={this.setUsernameState}
changed={this.state.changed} />
</>
);
}
}