Skip to content

Commit

Permalink
[fixed] Remove cross import between Button & ButtonInput
Browse files Browse the repository at this point in the history
They were importing each other which causes an issue when using
ButtonInput for server side react rendering under node. Possibly not an
issue when they are bundled into the same client side file.

We remove the import Button and move the definition of the 'types' into
Button which is then referenced from ButtonInput as that already has to
import Button.

We keep the ButtonInput.types to preserve the interface.
  • Loading branch information
michaeljones committed Oct 21, 2015
1 parent 4901d2c commit 6e37b27
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import React from 'react';
import classNames from 'classnames';
import BootstrapMixin from './BootstrapMixin';
import elementType from 'react-prop-types/lib/elementType';
import ButtonInput from './ButtonInput';

const types = ['button', 'reset', 'submit'];

const Button = React.createClass({
mixins: [BootstrapMixin],
Expand All @@ -24,7 +25,7 @@ const Button = React.createClass({
* @type {("button"|"reset"|"submit")}
* @defaultValue 'button'
*/
type: React.PropTypes.oneOf(ButtonInput.types)
type: React.PropTypes.oneOf(types)
},

getDefaultProps() {
Expand Down Expand Up @@ -101,4 +102,6 @@ const Button = React.createClass({
}
});

Button.types = types;

export default Button;
2 changes: 1 addition & 1 deletion src/ButtonInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ButtonInput extends InputBase {
}
}

ButtonInput.types = ['button', 'reset', 'submit'];
ButtonInput.types = Button.types;

ButtonInput.defaultProps = {
type: 'button'
Expand Down

0 comments on commit 6e37b27

Please sign in to comment.