mirror of
https://github.com/Mastermindzh/react-starter-kit.git
synced 2025-08-23 17:44:52 +02:00
Added CypressStrictMode
This commit is contained in:
16
src/infrastructure/CypressStrictMode.tsx
Normal file
16
src/infrastructure/CypressStrictMode.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
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>;
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user