by chenglou · 12y ago · 0 comments
converter = new Showdown.converter()
MarkdownEditor = React.createClass
getInitialState: () -> value: 'Type some *markdown* here!'
handleChange: (e) -> @setState(value: e.target.value)
render: () ->
d = React.DOM
d.div(
d.h3(null, 'Input'),
d.textarea(onChange: @handleChange, value: @state.value),
d.h3(null, 'Output'),
d.div(dangerouslySetInnerHTML: __html: converter.makeHtml(@state.value))
)
React.renderComponent MarkdownEditor(), document.querySelector('.container')
Showing a LOC comparison (and not even from the same dialect of a language) isn't a good proof for what you're trying to demonstrate. Clarity, simplicity, and debuggability all count. Removing a few extra lines of (non-boilerplate) code compared to React doesn't make the library simpler to work with.We have a strong preference for Haml and CoffeeScript dialects so that's how we present our demos. I built jsfiddles based on how each framework presented their own product.
Also, React is a view library, not a full-stack framework. The fact that it's put on the same level as other real JS frameworks is an acknowledgment of its paradigm's power and usefulness. So I guess people viewing it as a framework is a misleading but very telling phenomenon.
That being said, good luck with the project!