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

Commit d556cff

Browse files
committed
closes 154
1 parent 6ae3163 commit d556cff

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
@@ -477,6 +477,25 @@ def render
477477
end
478478
end
479479

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

0 commit comments

Comments
 (0)