You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-13 23:41:50 +03:00
Move waitForUpdate to test-utils
This commit is contained in:
@ -302,3 +302,23 @@ export function wrapInMatrixClientContext(WrappedComponent) {
|
||||
}
|
||||
return Wrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call fn before calling componentDidUpdate on a react component instance, inst.
|
||||
* @param {React.Component} inst an instance of a React component.
|
||||
* @returns {Promise} promise that resolves when componentDidUpdate is called on
|
||||
* given component instance.
|
||||
*/
|
||||
export function waitForUpdate(inst) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const cdu = inst.componentDidUpdate;
|
||||
|
||||
inst.componentDidUpdate = (prevProps, prevState, snapshot) => {
|
||||
resolve();
|
||||
|
||||
if (cdu) cdu(prevProps, prevState, snapshot);
|
||||
|
||||
inst.componentDidUpdate = cdu;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user