This repository was archived by the owner on May 17, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +15
-16
lines changed
Expand file tree Collapse file tree 1 file changed +15
-16
lines changed Original file line number Diff line number Diff line change @@ -7,40 +7,39 @@ import FormInput from './form-input';
77class PortInput extends React . PureComponent {
88 static displayName = 'PortInput' ;
99
10- static propTypes = { port : PropTypes . number , isPortChanged : PropTypes . bool } ;
10+ static propTypes = {
11+ port : PropTypes . number // initial port
12+ } ;
13+
14+ constructor ( props ) {
15+ super ( props ) ;
16+ this . state = { port : props . port } ;
17+ }
1118
1219 /**
1320 * Changes port.
1421 *
1522 * @param {Object } evt - evt.
1623 */
1724 onPortChanged ( evt ) {
18- Actions . onPortChanged ( + evt . target . value ) ;
25+ this . setState ( { port : evt . target . value } ) ;
26+ Actions . onPortChanged ( evt . target . value ? + evt . target . value : 27017 ) ;
1927 }
2028
21- /**
22- * Gets port.
23- *
24- * @returns {Number } port.
25- */
26- getPort ( ) {
27- if ( this . props . isPortChanged === false ) {
28- return 27017 ;
29+ render ( ) {
30+ if ( ! this . state ) {
31+ return ;
2932 }
3033
31- return + this . props . port ;
32- }
33-
34- render ( ) {
3534 return (
3635 < FormInput
3736 label = "Port"
3837 name = "port"
3938 placeholder = "27017"
4039 changeHandler = { this . onPortChanged . bind ( this ) }
41- value = { this . getPort ( ) }
40+ value = { this . state . port }
4241 type = "number"
43- otherInputAttributes = { { min : 1 , max : 65536 } } />
42+ otherInputAttributes = { { min : 1 , max : 65536 } } />
4443 ) ;
4544 }
4645}
You can’t perform that action at this time.
0 commit comments