Skip to content

Commit 8b9104d

Browse files
committed
Fix use of deprecated setProps()
1 parent 4a2b528 commit 8b9104d

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

tests/browser/browser.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,16 @@ describe('Routing', function() {
8484

8585
var App = React.createClass({
8686

87+
getInitialState: function() {
88+
return {};
89+
},
90+
8791
render: function() {
88-
return div({onClick: this.props.onClick},
92+
return div({onClick: this.state.onClick},
8993
Locations({
9094
ref: 'router', className: 'App',
91-
onNavigation: this.props.navigationHandler,
92-
onBeforeNavigation: this.props.beforeNavigationHandler
95+
onNavigation: this.state.navigationHandler,
96+
onBeforeNavigation: this.state.beforeNavigationHandler
9397
},
9498
Location({
9599
path: '/__zuul',
@@ -140,8 +144,8 @@ describe('Routing', function() {
140144
},
141145

142146
gotoURL: function(url) {
143-
if (this.props.gotoURL) {
144-
this.props.gotoURL(url);
147+
if (this.state.gotoURL) {
148+
this.state.gotoURL(url);
145149
}
146150
},
147151

@@ -229,7 +233,7 @@ describe('Routing', function() {
229233
it('calls onBeforeNaviation and onNavigation', function(done) {
230234
assertRendered('mainpage');
231235
var called = [];
232-
app.setProps({
236+
app.setState({
233237
beforeNavigationHandler: function (nextPath) {
234238
called.push(nextPath);
235239
},
@@ -294,7 +298,7 @@ describe('Routing', function() {
294298

295299
var assertNotNavigated = function(done) {
296300
assertRendered('mainpage');
297-
app.setProps({
301+
app.setState({
298302
onClick: function(event) {
299303
// Make sure that the event hasn't had its default prevented by the
300304
// CaptureClicks component.
@@ -339,7 +343,7 @@ describe('Routing', function() {
339343

340344
it("doesn't navigate if the href has another host", function(done) {
341345
assertRendered('mainpage');
342-
app.setProps({
346+
app.setState({
343347
onClick: function(event) {
344348
// Make sure that the event hasn't had its default prevented by the
345349
// CaptureClicks component.
@@ -354,7 +358,7 @@ describe('Routing', function() {
354358

355359
it('follows the link if the href has no matching route', function(done) {
356360
assertRendered('mainpage');
357-
app.setProps({
361+
app.setState({
358362
gotoURL: function(url) {
359363
done();
360364
}
@@ -365,7 +369,7 @@ describe('Routing', function() {
365369
it('doesn\'t route bare hash links', function(done) {
366370
assertRendered('mainpage');
367371
var called = false;
368-
app.setProps({
372+
app.setState({
369373
gotoURL: function(url) {
370374
called = true;
371375
done();
@@ -456,7 +460,7 @@ describe('Nested routers', function() {
456460
describe('CaptureClicks component', function() {
457461
it('navigates to a subroute via onClick event', function(done) {
458462
assertRendered('mainpage');
459-
app.setProps({
463+
app.setState({
460464
gotoURL: function(url) {
461465
done(new Error('Followed link to ' + url));
462466
}
@@ -470,7 +474,7 @@ describe('Nested routers', function() {
470474

471475
it('navigates to a subroute via onClick event (root case)', function(done) {
472476
assertRendered('mainpage');
473-
app.setProps({
477+
app.setState({
474478
gotoURL: function(url) {
475479
done(new Error('Followed link to ' + url));
476480
}

0 commit comments

Comments
 (0)