allow to use button as a function

This commit is contained in:
Sérgio Ramos 2017-01-09 12:37:05 +00:00
parent 69627def2a
commit 77ac03962e

View File

@ -1,5 +1,6 @@
const constants = require('../../shared/constants'); const constants = require('../../shared/constants');
const fns = require('../../shared/functions'); const fns = require('../../shared/functions');
const isString = require('lodash.isstring');
const match = require('../../shared/match'); const match = require('../../shared/match');
const React = require('react'); const React = require('react');
const Styled = require('styled-components'); const Styled = require('styled-components');
@ -139,6 +140,15 @@ const StyledAnchor = styled.a`
const Button = (props) => { const Button = (props) => {
// support FormattedMessage
if (isString(props)) {
return (
<StyledButton>
{props}
</StyledButton>
);
}
return props.href ? ( return props.href ? (
<StyledAnchor {...props} /> <StyledAnchor {...props} />
) : ( ) : (