-
Notifications
You must be signed in to change notification settings - Fork 47.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6121 from raineroviir/rainer
Fix #6114 - Calling setState inside getChildContext should warn
- Loading branch information
Showing
5 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/isomorphic/devtools/ReactInvalidSetStateWarningDevTool.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright 2016-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @providesModule ReactInvalidSetStateWarningDevTool | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var warning = require('warning'); | ||
|
||
if (__DEV__) { | ||
var processingChildContext = false; | ||
|
||
var warnInvalidSetState = function() { | ||
warning( | ||
!processingChildContext, | ||
'setState(...): Cannot call setState() inside getChildContext()' | ||
); | ||
}; | ||
} | ||
|
||
var ReactInvalidSetStateWarningDevTool = { | ||
onBeginProcessingChildContext() { | ||
processingChildContext = true; | ||
}, | ||
onEndProcessingChildContext() { | ||
processingChildContext = false; | ||
}, | ||
onSetState() { | ||
warnInvalidSetState(); | ||
}, | ||
}; | ||
|
||
module.exports = ReactInvalidSetStateWarningDevTool; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters