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

Commit 6d71be8

Browse files
committed
def collected params method on proxy, closes #100
Conflicts: spec/react/param_declaration_spec.rb
1 parent 65830c5 commit 6d71be8

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lib/react/component/class_methods.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ def collect_other_params_as(name)
8282
define_method(name) do
8383
@_all_others ||= self.class.validator.undefined_props(props)
8484
end
85+
86+
validator_in_lexial_scope = validator
87+
props_wrapper.define_method(name) do
88+
@_all_others ||= validator_in_lexial_scope.undefined_props(props)
89+
end
8590
end
8691

8792
def define_state(*states, &block)

spec/react/param_declaration_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
if opal?
44
describe 'the param macro' do
5+
it 'defines collect_other_params_as method on params proxy' do
6+
stub_const 'Foo', Class.new(React::Component::Base)
7+
Foo.class_eval do
8+
collect_other_params_as :foo
9+
10+
def render
11+
div { params.foo[:bar] }
12+
end
13+
end
14+
15+
html = React.render_to_static_markup(React.create_element(Foo, { bar: 'biz' }))
16+
expect(html).to eq('<div>biz</div>')
17+
end
18+
519
it "can create and access a required param" do
620
stub_const 'Foo', Class.new(React::Component::Base)
721
Foo.class_eval do

0 commit comments

Comments
 (0)