Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

Commit 46de6b0

Browse files
committed
Merge pull request #16 from zetachang/native-element
Native React::Element
2 parents c19a3a5 + b026870 commit 46de6b0

File tree

17 files changed

+207
-120
lines changed

17 files changed

+207
-120
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## edge (upcoming 0.2.0)
2+
3+
* Deprecating `jsx` helper
4+
* Deprecating `React::Element.new`, use `React.create_element` instead
5+
* `React::Element` is now toll-free bridge to [ReactElement](http://facebook.github.io/react/docs/glossary.html#react-elements)
6+
* `React::Element#props` now return a `Hash` rather than a `Native`
7+
* `React::Element#children` now handling empty child & single child correctly

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,12 @@ class App
150150
include React::Component
151151

152152
def render
153-
jsx(%x{
153+
%x{
154154
<div>
155155
<h1>Outer</h1>
156156
<Fancy>{ #{5.times.to_a.join(",")} }</Fancy>
157157
</div>
158-
})
158+
}
159159
end
160160
end
161161

example/basic-jsx/Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: ../..
33
specs:
4-
react.rb (0.0.2)
4+
react.rb (0.1.0)
55
opal (~> 0.6.0)
66
opal-activesupport
77
sprockets-es6
@@ -10,7 +10,7 @@ PATH
1010
GEM
1111
remote: https://rubygems.org/
1212
specs:
13-
babel-source (4.7.3)
13+
babel-source (4.7.16)
1414
babel-transpiler (0.6.0)
1515
babel-source (>= 4.0, < 5)
1616
execjs (~> 2.0)

example/basic-jsx/example.jsx.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,16 @@ class Clock
88
def render
99
message = "React has been successfully running for #{params[:elapsed].round} seconds."
1010

11-
jsx %x{
12-
<p>{#{message}}</p>
13-
}
11+
12+
`<p>{#{message}}</p>`
1413
end
1514
end
1615

1716
class ExampleApp
1817
include React::Component
1918

2019
def render
21-
jsx(%x{
22-
<Clock elapsed={#{params[:elapsed]}} />
23-
})
20+
`<Clock elapsed={#{params[:elapsed]}} />`
2421
end
2522
end
2623

@@ -29,7 +26,7 @@ def render
2926
start = Time.now
3027

3128
$window.every(0.05) do
32-
element = React::Element.new(`<ExampleApp elapsed={#{Time.now - start}}/>`)
29+
element = `<ExampleApp elapsed={#{Time.now - start}}/>`
3330
container = `document.getElementById('container')`
3431
React.render element, container
3532
end

example/react-tutorial/Gemfile.lock

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
PATH
22
remote: ../..
33
specs:
4-
react.rb (0.0.1)
4+
react.rb (0.1.0)
55
opal (~> 0.6.0)
66
opal-activesupport
7+
sprockets-es6
8+
therubyracer
79

810
GEM
911
remote: https://rubygems.org/
1012
specs:
11-
hike (1.2.3)
13+
babel-source (4.7.16)
14+
babel-transpiler (0.6.0)
15+
babel-source (>= 4.0, < 5)
16+
execjs (~> 2.0)
17+
execjs (2.4.0)
1218
json (1.8.2)
13-
multi_json (1.10.1)
19+
libv8 (3.16.14.7)
1420
opal (0.6.3)
1521
source_map
1622
sprockets
@@ -21,19 +27,23 @@ GEM
2127
rack (1.6.0)
2228
rack-protection (1.5.3)
2329
rack
24-
react-source (0.12.2)
25-
sinatra (1.4.5)
30+
react-source (0.13.1)
31+
ref (1.0.5)
32+
sinatra (1.4.6)
2633
rack (~> 1.4)
2734
rack-protection (~> 1.4)
28-
tilt (~> 1.3, >= 1.3.4)
35+
tilt (>= 1.3, < 3)
2936
source_map (3.0.1)
3037
json
31-
sprockets (2.12.3)
32-
hike (~> 1.2)
33-
multi_json (~> 1.0)
38+
sprockets (3.0.0.rc.1)
3439
rack (~> 1.0)
35-
tilt (~> 1.1, != 1.3.0)
36-
tilt (1.4.1)
40+
sprockets-es6 (0.6.0)
41+
babel-transpiler
42+
sprockets (~> 3.0.0.beta)
43+
therubyracer (0.12.1)
44+
libv8 (~> 3.16.14.0)
45+
ref
46+
tilt (2.0.1)
3747

3848
PLATFORMS
3949
ruby

example/react-tutorial/config.ru

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ get '/' do
4242
<link rel="stylesheet" href="base.css" />
4343
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
4444
<script src="http://cdnjs.cloudflare.com/ajax/libs/showdown/0.3.1/showdown.min.js"></script>
45-
<script src="/assets/react-with-addons.min.js"></script>
45+
<script src="/assets/react-with-addons.js"></script>
4646
<script src="/assets/example.js"></script>
4747
</head>
4848
<body>

example/react-tutorial/example.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,5 @@ def render
100100

101101

102102
Document.ready? do
103-
React.render React.create_element(CommentBox, url: "comments.json", poll_interval: 2000), Element.find('#content').get(0)
103+
React.render React.create_element(CommentBox, url: "comments.json", poll_interval: 2000), `document.getElementById('content')`
104104
end

example/todos/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ gem 'opal-jquery', :github => 'opal/opal-jquery'
66
gem 'vienna', :github => 'opal/vienna', :ref => '593335cbd7fb99ce471fa720e9b9c849d99b8dda'
77
gem 'opal-haml', :github => 'opal/opal-haml'
88
gem 'opal-rspec', '0.3.0.beta2'
9-
gem 'react.rb', :path => "../.."
9+
gem 'react.rb', '~> 0.0.2'
1010
gem 'thin'
1111
gem 'react-source'

example/todos/Gemfile.lock

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@ GIT
3232
opal-activesupport
3333
opal-jquery
3434

35-
PATH
36-
remote: ../..
37-
specs:
38-
react.rb (0.0.1)
39-
opal (~> 0.6.0)
40-
opal-activesupport
41-
4235
GEM
4336
remote: https://rubygems.org/
4437
specs:
@@ -56,6 +49,9 @@ GEM
5649
rack (1.5.2)
5750
rake (10.1.1)
5851
react-source (0.12.2)
52+
react.rb (0.0.2)
53+
opal (~> 0.6.0)
54+
opal-activesupport
5955
source_map (3.0.1)
6056
json
6157
sprockets (2.12.3)
@@ -79,6 +75,6 @@ DEPENDENCIES
7975
opal-rspec (= 0.3.0.beta2)
8076
rake
8177
react-source
82-
react.rb!
78+
react.rb (~> 0.0.2)
8379
thin
8480
vienna!

lib/react/api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def self.create_element(type, properties = {}, &block)
3232
end
3333
end
3434

35-
return React::Element.new(`React.createElement.apply(null, #{params})`)
35+
return `React.createElement.apply(null, #{params})`
3636
end
3737

3838
def self.clear_component_class_cache

0 commit comments

Comments
 (0)