Skip to content

Commit 1f86f44

Browse files
committed
Moved the logic for <TextWidget> into a new separate file 'webpack_in/text_widget.jsx'.
1 parent 0919b00 commit 1f86f44

File tree

2 files changed

+41
-28
lines changed

2 files changed

+41
-28
lines changed

webpack_in/entry.jsx

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,9 @@ import ReactDOM from 'react-dom';
1313
import ButtonWidget from './button_widget.jsx';
1414
import HelloWidget from './hello_widget.jsx';
1515
import Styles from './styles.es';
16+
import TextWidget from './text_widget.jsx';
1617

1718

18-
class TextWidget extends React.Component {
19-
constructor(props) {
20-
super(props);
21-
22-
this.state = {
23-
text: "Some text here...."
24-
};
25-
}
26-
27-
render() {
28-
return (
29-
<div style={ Styles.common }>
30-
<div style={ Styles.content }>{ this.state.text }</div>
31-
<ButtonWidget caption="Change text..."
32-
onClick={() => {
33-
const strTextNew = prompt("Please enter text to display:",
34-
this.state.text);
35-
if (strTextNew === null) {
36-
return;
37-
}
38-
39-
this.setState({...this.state, text: strTextNew});
40-
}}/>
41-
</div>
42-
);
43-
}
44-
}
45-
4619
class ListItem extends React.Component {
4720
render() {
4821
return (<li><input type='checkbox'

webpack_in/text_widget.jsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// This file 'text_widget.jsx' is part of an example for building a multi-widget React front-end
2+
// app step by step as outlined in the tutorial blog at
3+
// http://maratbn.com/blogs/2018/07/02/react-multi-widget/
4+
5+
6+
import React from 'react';
7+
8+
import ButtonWidget from './button_widget.jsx';
9+
import Styles from './styles.es';
10+
11+
12+
class TextWidget extends React.Component {
13+
constructor(props) {
14+
super(props);
15+
16+
this.state = {
17+
text: "Some text here...."
18+
};
19+
}
20+
21+
render() {
22+
return (
23+
<div style={ Styles.common }>
24+
<div style={ Styles.content }>{ this.state.text }</div>
25+
<ButtonWidget caption="Change text..."
26+
onClick={() => {
27+
const strTextNew = prompt("Please enter text to display:",
28+
this.state.text);
29+
if (strTextNew === null) {
30+
return;
31+
}
32+
33+
this.setState({...this.state, text: strTextNew});
34+
}}/>
35+
</div>
36+
);
37+
}
38+
}
39+
40+
export default TextWidget;

0 commit comments

Comments
 (0)