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

Commit c994c1a

Browse files
catmandozetachang
authored andcommitted
closes 154
1 parent 10347fe commit c994c1a

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/react/component/class_methods.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def prop_types
4343
_componentValidator: %x{
4444
function(props, propName, componentName) {
4545
var errors = #{validator.validate(Hash.new(`props`))};
46-
var error = new Error(#{"In component `" + self.name + "`\n" + `errors`.join("\n")});
46+
var error = new Error(#{"In component `#{name}`\n" + `errors`.join("\n")});
4747
return #{`errors`.count > 0 ? `error` : `undefined`};
4848
}
4949
}

spec/react/component_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,25 @@ def render
476476
end
477477
end
478478

479+
describe 'Anonymous Component' do
480+
it "will not generate spurious warning messages" do
481+
foo = Class.new(React::Component::Base)
482+
foo.class_eval do
483+
def render; "hello" end
484+
end
485+
486+
%x{
487+
var log = [];
488+
var org_warn_console = window.console.warn;
489+
var org_error_console = window.console.error
490+
window.console.warn = window.console.error = function(str){log.push(str)}
491+
}
492+
renderToDocument(foo)
493+
`window.console.warn = org_warn_console; window.console.error = org_error_console;`
494+
expect(`log`).to eq([])
495+
end
496+
end
497+
479498
describe 'Event handling' do
480499
before do
481500
stub_const 'Foo', Class.new

0 commit comments

Comments
 (0)