adding "to" prop to allow for button to use react-router correctly

This commit is contained in:
Alex Windett 2017-02-28 12:22:48 +00:00
parent 5b4887d18b
commit eb742b6266
2 changed files with 6 additions and 4 deletions

View File

@ -33,7 +33,7 @@ const Projects = ({
{empty} {empty}
<Row> <Row>
<Column xs={12}> <Column xs={12}>
<Button href={`/${org.id}/new-project`}> <Button to={`/${org.id}/new-project`}>
<FormattedMessage id='create-new' /> <FormattedMessage id='create-new' />
</Button> </Button>
</Column> </Column>

View File

@ -125,7 +125,7 @@ const StyledButton = styled.button`
} }
`; `;
const StyledAnchor = styled.a` const StyledAnchor = styled(Link)`
display: inline-block; display: inline-block;
${style} ${style}
`; `;
@ -147,11 +147,12 @@ const Button = (props) => {
const { const {
href = '', href = '',
to = '',
rr = false rr = false
} = props; } = props;
const Views = [ const Views = [
() => !href ? StyledButton : null, () => !to || !href ? StyledButton : null,
() => !rr ? StyledAnchor : null, () => !rr ? StyledAnchor : null,
() => StyledLink () => StyledLink
]; ];
@ -165,7 +166,8 @@ const Button = (props) => {
Button.propTypes = { Button.propTypes = {
href: React.PropTypes.string, href: React.PropTypes.string,
rr: React.PropTypes.bool rr: React.PropTypes.bool,
to: React.PropTypes.string
}; };
export default Baseline( export default Baseline(