Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Moved the logic for <ButtonWidget> into a new separate file 'webpack_…
…in/button_widget.jsx'.
  • Loading branch information
maratbn committed Aug 5, 2018
1 parent 0155a62 commit 59750a0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
27 changes: 27 additions & 0 deletions webpack_in/button_widget.jsx
@@ -0,0 +1,27 @@
// This file 'button_widget.jsx' is part of an example for building a multi-widget React front-end
// app step by step as outlined in the tutorial blog at
// http://maratbn.com/blogs/2018/07/02/react-multi-widget/


import PropTypes from 'prop-types';
import React from 'react';


class ButtonWidget extends React.Component {
render() {
return (
<button style={{ margin: '1em'}}
disabled={ this.props.isDisabled }
onClick={ this.props.onClick }>{ this.props.caption }</button>
);
}
}

ButtonWidget.propTypes = {
caption: PropTypes.string.isRequired,
isDisabled: PropTypes.bool,
onClick: PropTypes.func
};


export default ButtonWidget;
17 changes: 1 addition & 16 deletions webpack_in/entry.jsx
Expand Up @@ -10,25 +10,10 @@ import PropTypes from 'prop-types';
import React from 'react';
import ReactDOM from 'react-dom';

import ButtonWidget from './button_widget.jsx';
import Styles from './styles.es';


class ButtonWidget extends React.Component {
render() {
return (
<button style={{ margin: '1em'}}
disabled={ this.props.isDisabled }
onClick={ this.props.onClick }>{ this.props.caption }</button>
);
}
}

ButtonWidget.propTypes = {
caption: PropTypes.string.isRequired,
isDisabled: PropTypes.bool,
onClick: PropTypes.func
};

class HelloWidget extends React.Component {
render() {
return (
Expand Down

0 comments on commit 59750a0

Please sign in to comment.