console.error(['MUI: Too many re-renders. The layout is unstable.','TextareaAutosize limits the number of renders to prevent an infinite loop.'].join('\n'));
}
}
returnprevState;
};
constsyncHeight=React.useCallback(()=>{
constnewState=getUpdatedState();
if(isEmpty(newState)){
return;
}
setState(prevState=>{
returnupdateState(prevState,newState);
});
},[getUpdatedState]);
constsyncHeightWithFlushSycn=()=>{
constnewState=getUpdatedState();
if(isEmpty(newState)){
return;
}
// In React 18, state updates in a ResizeObserver's callback are happening after the paint which causes flickering
// when doing some visual updates in it. Using flushSync ensures that the dom will be painted after the states updates happen
// Related issue - https://github.com/facebook/react/issues/24331
flushSync(()=>{
setState(prevState=>{
returnupdateState(prevState,newState);
});
});
};
React.useEffect(()=>{
consthandleResize=debounce(()=>{
renders.current=0;
// If the TextareaAutosize component is replaced by Suspense with a fallback, the last
// ResizeObserver's handler that runs because of the change in the layout is trying to
// access a dom node that is no longer there (as the fallback component is being shown instead).
// See https://github.com/mui/material-ui/issues/32640