react.rb icon indicating copy to clipboard operation
react.rb copied to clipboard

Upgrade to React v0.13

Open zetachang opened this issue 9 years ago • 1 comments

React.js v0.13 is released last month (http://facebook.github.io/react/blog/2015/03/10/react-v0.13.html). Some work need to be done in react.rb to catch up this release, there is https://github.com/zetachang/react.rb/pull/17 which tracks all the changes introduced.

Depends on react-source

Previously , react-source gem v0.12.0 is only used as development dependency. Since the changes introduced will break in version under 0.13, so we will explicitly depends on react-source.

Also, you can now include the react source simply by adding a line as below without manually download or manage the source.

<%= javascript_include_tag 'react.js' %>

Toll-free bridge React::Component

We are introducing toll-free bridge React::Component.

Previously, the Ruby instance created through React.render(Foo) is actually not the component instance created by React.js framework. The Ruby instance is created during first mount and cached inside the actual component instance as a property.

Upgrading

All the DSL you got by include React::Component remains almost the same. Only difference is that previously the native ReactComponent will be passed as the first argument in the initializer of your class. But since the instance is actually the real ReactComponent instance. So simply refer to self in your initializer if you want to do stuff with it.

Other breaking changes

  • props are immutable now, so set_props & set_props! are deprecated, see official blog post for upgrading details.
  • set_state! are deprecated (since replaceState is deprecated , see original issue for more details)
  • dom_node is deprecated in favor of React.find_dom_node
  • React.find_dom_node return a plain DOM object rather than a Native

I will move all the details to wiki when this is actually done, and feel free to leave a comment if there is any concern or clarification needed. :wink:

zetachang avatar Apr 12 '15 09:04 zetachang