MCPcopy Create free account
hub / github.com/reactjs/react-modal / componentDidUpdate

Method componentDidUpdate

src/components/ModalPortal.js:101–133  ·  view source on GitHub ↗
(prevProps, prevState)

Source from the content-addressed store, hash-verified

99 }
100
101 componentDidUpdate(prevProps, prevState) {
102 if (process.env.NODE_ENV !== "production") {
103 if (prevProps.bodyOpenClassName !== this.props.bodyOpenClassName) {
104 // eslint-disable-next-line no-console
105 console.warn(
106 'React-Modal: "bodyOpenClassName" prop has been modified. ' +
107 "This may cause unexpected behavior when multiple modals are open."
108 );
109 }
110 if (prevProps.htmlOpenClassName !== this.props.htmlOpenClassName) {
111 // eslint-disable-next-line no-console
112 console.warn(
113 'React-Modal: "htmlOpenClassName" prop has been modified. ' +
114 "This may cause unexpected behavior when multiple modals are open."
115 );
116 }
117 }
118
119 if (this.props.isOpen && !prevProps.isOpen) {
120 this.open();
121 } else if (!this.props.isOpen && prevProps.isOpen) {
122 this.close();
123 }
124
125 // Focus only needs to be set once when the modal is being opened
126 if (
127 this.props.shouldFocusAfterRender &&
128 this.state.isOpen &&
129 !prevState.isOpen
130 ) {
131 this.focusContent();
132 }
133 }
134
135 componentWillUnmount() {
136 if (this.state.isOpen) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected