scup / atellier

The smartest way to share interactive components with your team.
http://scup.github.io/atellier/
MIT License
995 stars 33 forks source link

defaultProps are ignored #38

Open sompylasar opened 8 years ago

sompylasar commented 8 years ago

Default UI state for PropTypes.bool props always render to true (switched on) regardless of the defaultProps of false.

Looks like this line is relevant: https://github.com/scup/atellier/blob/19587d32278176a25bc720e8a3f23f5b5f668f62/src/PropertiesContainer.js#L117

const defaultProps = this._properties[prop] || values;

this._properties[prop] is either false, the value from the component's defaultProps, or undefined because defaultProps aren't accounted for here (if I understand this piece correctly).

So it falls back to the default value which is true for PropTypes.bool.

sompylasar commented 8 years ago

Looks like there is more to this issue.

The component props are not initialized with defaultProps in the Workspace state: https://github.com/scup/atellier/blob/375cf7c606d129352863aa9548415610ef764b07/src/Workspace.js#L20

The falsy values are nullified here: https://github.com/scup/atellier/blob/375cf7c606d129352863aa9548415610ef764b07/src/PropertiesContainer.js#L102-L103

sompylasar commented 8 years ago

Related: #41

lucasconstantino commented 8 years ago

+1