-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit d5cfe08 Author: John Benavides <john@mailtrack.io> Date: Tue Jul 3 17:30:55 2018 +0200 change class components for functions
- Loading branch information
John Benavides
committed
Jul 4, 2018
1 parent
d4b62d0
commit f76b247
Showing
71 changed files
with
2,762 additions
and
2,992 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,39 @@ | ||
import React, { PureComponent } from 'react'; | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import classnames from 'classnames'; | ||
|
||
export default class Box extends PureComponent { | ||
static propTypes = { | ||
children: PropTypes.node, | ||
className: PropTypes.string, | ||
style: PropTypes.shape({}), | ||
renderAs: PropTypes.oneOfType([ | ||
PropTypes.string, | ||
PropTypes.func, | ||
]), | ||
} | ||
const Box = ({ | ||
children, | ||
className, | ||
renderAs, | ||
...props | ||
}) => { | ||
const Element = renderAs; | ||
return ( | ||
<Element | ||
{...props} | ||
className={classnames('box', className)} | ||
> | ||
{children} | ||
</Element> | ||
); | ||
}; | ||
|
||
static defaultProps = { | ||
children: null, | ||
className: '', | ||
style: {}, | ||
renderAs: 'div', | ||
} | ||
Box.propTypes = { | ||
children: PropTypes.node, | ||
className: PropTypes.string, | ||
style: PropTypes.shape({}), | ||
renderAs: PropTypes.oneOfType([ | ||
PropTypes.string, | ||
PropTypes.func, | ||
]), | ||
}; | ||
|
||
render() { | ||
const { | ||
children, | ||
className, | ||
renderAs, | ||
...props | ||
} = this.props; | ||
const Element = renderAs; | ||
return ( | ||
<Element | ||
{...props} | ||
className={classnames('box', className)} | ||
> | ||
{children} | ||
</Element> | ||
); | ||
} | ||
} | ||
Box.defaultProps = { | ||
children: null, | ||
className: '', | ||
style: {}, | ||
renderAs: 'div', | ||
}; | ||
|
||
export default Box; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.