Last active
September 29, 2015 07:11
-
-
Save silppuri/6dd4ed2d3fcae23813b4 to your computer and use it in GitHub Desktop.
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
React = require("react") | |
classnames = require("classnames") | |
ReadOnly = (CompositeComponent) -> class extends React.Component | |
render: -> | |
<CompositeComponent | |
{...@props} | |
className={classnames("read-only": @props.read)} | |
readOnly={@props.read} | |
/> | |
FormItem = ReadOnly(require("form-item")) |
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
let ReadOnly = CompositeComponent => class extends React.Component { | |
render() { | |
return <CompositeComponent {...this.props} readOnly={this.state.read}/> | |
} | |
} | |
class FormItem extends React.Component { | |
render() { | |
return <input readOnly={this.props.readOnly}/> | |
} | |
} | |
let Enhanced = ReadOnly(FormItem); | |
React.render(<Enhanced readOnly={false}/>, document.getElementById("app")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment