mirror of
https://github.com/Mastermindzh/react-starter-kit.git
synced 2025-08-23 09:35:01 +02:00
17 lines
444 B
TypeScript
17 lines
444 B
TypeScript
import React, { FunctionComponent, ReactNode } from "react";
|
|
|
|
type Props = { children?: ReactNode };
|
|
|
|
/**
|
|
* React StrictMode that disables itself when detected to be running in Cypress
|
|
*/
|
|
export const CypressStrictMode: FunctionComponent<Props> = ({ children }) => {
|
|
const isInCypress = (window as any).Cypress;
|
|
|
|
if (isInCypress) {
|
|
return <>{children}</>;
|
|
} else {
|
|
return <React.StrictMode>{children}</React.StrictMode>;
|
|
}
|
|
};
|