These are chat archives for chandu0101/scalajs-react-components

May 2016
May 14 2016 03:00

Hi, i want to wrap Draft.js (A react Editor by Facebook),
i'm going to wrap it into my scalajs project. but i don't know how to implement the function *render and setSate. code snippet's is above

class MyEditor extends React.Component {
  constructor(props) {
    this.state = {editorState: EditorState.createEmpty()};
    this.onChange = (editorState) => this.setState({editorState});
  render() {
    const {editorState} = this.state;
    return <Editor editorState={editorState} onChange={this.onChange} />;

  <MyEditor />,

And it's mine, but i fail to update state fo Editor.

val ref_editor = Ref.toJS[EditorM]("editor")
  class Backend(scope: BackendScope[Unit, Unit]) {
    def onChange1(editorState: EditorState): Unit = {
    def render() = {
      val factory_editor = React.createFactory(Editor)
        factory_editor(EditorProp(ref = ref_editor,
          EditorStateStatic.createEmpty(),// how to do with this, it should be from  this.state.editorState?
          onChange = onChange1 _))
√ėyvind Raddum Berg
May 14 2016 17:23
phew, imagine doing that manually @chandu0101 xD
fixed the generator to parse react classes and methods on the component now, though its pretty much impossible to infer any types