Skip to content

Commit 78c0187

Browse files
committed
Merge pull request #105 from grahamcracker/0.12
update to react-source 0.12 final
2 parents b308749 + 359cfbb commit 78c0187

17 files changed

+21
-43
lines changed

README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,11 @@ Alternatively, you can include it directly as a separate script tag:
5858

5959
### JSX
6060

61-
To transform your JSX into JS, simply create `.js.jsx` files, and ensure that the file has the `/** @jsx React.DOM */` docblock. These files will be transformed on request, or precompiled as part of the `assets:precompile` task.
61+
To transform your JSX into JS, simply create `.js.jsx` files. These files will be transformed on request, or precompiled as part of the `assets:precompile` task.
6262

63-
CoffeeScript files can also be used, by creating `.js.jsx.coffee` files. You must use this form of the docblock at the top of each file: `###* @jsx React.DOM ###`. We also need to embed JSX inside backticks so CoffeeScript ignores the syntax it doesn't understand. Here's an example:
63+
CoffeeScript files can also be used, by creating `.js.jsx.coffee` files. We also need to embed JSX inside backticks so CoffeeScript ignores the syntax it doesn't understand. Here's an example:
6464

6565
```coffee
66-
###* @jsx React.DOM ###
67-
6866
Component = React.createClass
6967
render: ->
7068
`<ExampleComponent videos={this.props.videos} />`
@@ -191,8 +189,6 @@ In order for us to render your React components, we need to be able to find them
191189
This will bring in all files located in the `app/assets/javascripts/components` directory. You can organize your code however you like, as long as a request for `/assets/javascripts/components.js` brings in a concatenated file containing all of your React components, and each one has to be available in the global scope (either `window` or `global` can be used). For `.js.jsx` files this is not a problem, but if you are using `.js.jsx.coffee` files then the wrapper function needs to be taken into account:
192190

193191
```coffee
194-
###* @jsx React.DOM ###
195-
196192
Component = React.createClass
197193
render: ->
198194
`<ExampleComponent videos={this.props.videos} />`
@@ -258,8 +254,6 @@ end
258254
It is possible to use JSX with CoffeeScript. The caveat is that you will still need to include the docblock. Since CoffeeScript doesn't allow `/* */` style comments, we need to do something a little different. We also need to embed JSX inside backticks so CoffeeScript ignores the syntax it doesn't understand. Here's an example:
259255

260256
```coffee
261-
###* @jsx React.DOM ###
262-
263257
Component = React.createClass
264258
render: ->
265259
`<ExampleComponent videos={this.props.videos} />`

gemfiles/rails_3.1.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ source "http://rubygems.org"
55
gem "rails", "~> 3.1"
66
gem "sprockets", ">= 2.2.2"
77

8-
gemspec :path=>"../"
8+
gemspec :path => "../"

gemfiles/rails_3.2.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ source "http://rubygems.org"
44

55
gem "rails", "~> 3.2"
66

7-
gemspec :path=>"../"
7+
gemspec :path => "../"

gemfiles/rails_4.0.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ source "http://rubygems.org"
44

55
gem "rails", "~> 4.0"
66

7-
gemspec :path=>"../"
7+
gemspec :path => "../"

gemfiles/rails_4.0_with_therubyracer.gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
source "http://rubygems.org"
44

55
gem "rails", "~> 4.0"
6-
gem "therubyracer", "0.12.0", :platform=>:mri
6+
gem "therubyracer", "0.12.0", :platform => :mri
77

8-
gemspec :path=>"../"
8+
gemspec :path => "../"

gemfiles/rails_4.1.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ source "http://rubygems.org"
44

55
gem "rails", "~> 4.1"
66

7-
gemspec :path=>"../"
7+
gemspec :path => "../"

lib/assets/javascripts/react_ujs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
var constructor = window[className] || eval.call(window, className);
2626
var propsJson = node.getAttribute(PROPS_ATTR);
2727
var props = propsJson && JSON.parse(propsJson);
28-
React.renderComponent(constructor(props), node);
28+
React.render(React.createElement(constructor, props), node);
2929
}
3030
};
3131

lib/react/renderer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def render(component, args={})
7070
react_props = React::Renderer.react_props(args)
7171
jscode = <<-JS
7272
function() {
73-
return React.renderComponentToString(#{component}(#{react_props}));
73+
return React.renderToString(React.createElement(#{component}, #{react_props}));
7474
}()
7575
JS
7676
context.eval(jscode).html_safe

react-rails.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
2525

2626
s.add_dependency 'execjs'
2727
s.add_dependency 'rails', '>= 3.1'
28-
s.add_dependency 'react-source', '0.11.1'
28+
s.add_dependency 'react-source', '0.12'
2929
s.add_dependency 'connection_pool'
3030

3131
s.files = Dir[

test/dummy/app/assets/javascripts/components/Todo.js.jsx.coffee

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
###* @jsx React.DOM ###
2-
31
Todo = React.createClass
42
render: ->
53
`<li>{this.props.todo}</li>`

0 commit comments

Comments
 (0)