Skip to content
This repository was archived by the owner on Jul 19, 2019. It is now read-only.

Use default props #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Use default props
We could use `getDefaultProps` instead of a ternary expression inside render function body.
  • Loading branch information
mohebifar committed Apr 13, 2016
commit a6695e84f373a9ed68f3bdb1370d4243b52a6e8a
8 changes: 7 additions & 1 deletion src/Rectangle.art.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,17 @@ var Rectangle = React.createClass({
radiusBottomRight: PropTypes.number,
radiusBottomLeft: PropTypes.number,
},

getDefaultProps: function() {
return {
radius: 0
};
},

render: function() {
var width = this.props.width;
var height = this.props.height;
var radius = this.props.radius ? this.props.radius : 0;
var radius = this.props.radius;

// if unspecified, radius(Top|Bottom)(Left|Right) defaults to the radius
// property
Expand Down