Skip to content

Recent changes to React API #4

@alfaguru

Description

@alfaguru

Console errors get logged when the ReactJS::js method is called, including:

Warning: Something is calling a React component directly. Use a factory or JSX instead. See: http://fb.me/react-legacyfactory

I also had problems getting this method working at all, but that may have been due to other factors. Anyway, I rewrote it to suppress the errors, like this:

public function js($element, $return_var = null)
{
    $component_name = $this->component;
    $react = $this->react_prefix . 'React';
    $data = json_encode($this->data);
    $assignment = $return_var ? "$return_var = " : '';
    return "var component = $react.createFactory($component_name);\n" .
    "$assignment $react.render(component($data), document.querySelector('$element'));\n"
    ;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions