Closed
Description
React version: 0.0.0-235a6c4af
Steps To Reproduce
- render component with exptected propType warnings
- see logged errors
- call
PropTypes.resetWarningCache()
- render component with exptected propType warnings
- no more logged errors
Link to code example:
import React from "react";
import ReactDOM from "react-dom";
import PropTypes from "prop-types";
function Component({ children = "setting default to not crash react" }) {
return children;
}
Component.propTypes = { children: PropTypes.node.isRequired };
const rootElement = document.createElement("div");
ReactDOM.render(<Component />, rootElement);
PropTypes.resetWarningCache();
ReactDOM.render(<Component />, rootElement);
Behavior on 0.0.0-235a6c4af
Behavior on 16.13.0
The current behavior
Warnings are logged once
The expected behavior
Warnings are logged twice. This was the behavior in 16.13.0
Context
Useful for testing custom propTypes warnings. When a test is watched and modules can't be reset between runs resetWarningCache
was useful. Otherwise the test behavior would change between test runs.
Pretty sure this is caused by inlining prop-types
in #18127. I think we can keep inlining the code and only import the cache so that it is shared with the regular prop-types
package and PropTypes.resetWarningCache()
keeps working.