File tree Expand file tree Collapse file tree 2 files changed +41
-28
lines changed
Expand file tree Collapse file tree 2 files changed +41
-28
lines changed Original file line number Diff line number Diff line change @@ -13,36 +13,9 @@ import ReactDOM from 'react-dom';
1313import ButtonWidget from './button_widget.jsx' ;
1414import HelloWidget from './hello_widget.jsx' ;
1515import 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-
4619class ListItem extends React . Component {
4720 render ( ) {
4821 return ( < li > < input type = 'checkbox'
Original file line number Diff line number Diff line change 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 ;
You can’t perform that action at this time.
0 commit comments