-
Notifications
You must be signed in to change notification settings - Fork 47.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
108 additions
and
45 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
import ReactSharedInternals from 'shared/ReactSharedInternals'; | ||
|
||
let resetOwnerStackIntervalId: mixed = null; | ||
|
||
export function startResettingOwnerStackLimit() { | ||
if (__DEV__) { | ||
ReactSharedInternals.recentlyCreatedOwnerStacks = 0; | ||
|
||
if (typeof setInterval === 'function') { | ||
// Renderers might start in render but stop in commit. | ||
// So we need to be resilient against start being called multiple times. | ||
if (resetOwnerStackIntervalId !== null) { | ||
clearInterval((resetOwnerStackIntervalId: any)); | ||
} | ||
resetOwnerStackIntervalId = setInterval(() => { | ||
ReactSharedInternals.recentlyCreatedOwnerStacks = 0; | ||
}, 1000); | ||
} | ||
} else { | ||
// These errors should never make it into a build so we don't need to encode them in codes.json | ||
// eslint-disable-next-line react-internal/prod-error-codes | ||
throw new Error( | ||
'startResettingOwnerStackLimit should never be called in production mode. This is a bug in React.', | ||
); | ||
} | ||
} | ||
|
||
export function stopResettingOwnerStackLimit() { | ||
if (__DEV__) { | ||
if (typeof setInterval === 'function') { | ||
if (resetOwnerStackIntervalId !== null) { | ||
clearInterval((resetOwnerStackIntervalId: any)); | ||
resetOwnerStackIntervalId = null; | ||
} | ||
} | ||
} else { | ||
// These errors should never make it into a build so we don't need to encode them in codes.json | ||
// eslint-disable-next-line react-internal/prod-error-codes | ||
throw new Error( | ||
'stopResettingOwnerStackLimit should never be called in production mode. This is a bug in React.', | ||
); | ||
} | ||
} |