mirror of
https://github.com/Mastermindzh/react-starter-kit.git
synced 2025-01-20 10:31:00 +01:00
Added CypressStrictMode
This commit is contained in:
parent
c0a0ea66a6
commit
e20fea679a
@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [0.6.2] - 2022-08-15
|
||||||
|
|
||||||
|
- Added CypressStrictMode
|
||||||
|
|
||||||
## [0.6.1] - 2022-08-08
|
## [0.6.1] - 2022-08-08
|
||||||
|
|
||||||
- eslint now receives the glob itself
|
- eslint now receives the glob itself
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-starter-kit",
|
"name": "react-starter-kit",
|
||||||
"version": "0.6.1",
|
"version": "0.6.2",
|
||||||
"description": "A modern, create-react-app-based, starter kit for React projects",
|
"description": "A modern, create-react-app-based, starter kit for React projects",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react",
|
"react",
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import React from "react";
|
|
||||||
import { createRoot } from "react-dom/client";
|
import { createRoot } from "react-dom/client";
|
||||||
import { Provider } from "react-redux";
|
import { Provider } from "react-redux";
|
||||||
import { createGlobalStyle } from "styled-components";
|
import { createGlobalStyle } from "styled-components";
|
||||||
import App from "./App";
|
import App from "./App";
|
||||||
import { store } from "./app/store";
|
import { store } from "./app/store";
|
||||||
|
import { CypressStrictMode } from "./infrastructure/CypressStrictMode";
|
||||||
import "./infrastructure/i18n/init";
|
import "./infrastructure/i18n/init";
|
||||||
import { OidcProvider } from "./infrastructure/sso/OidcProvider";
|
import { OidcProvider } from "./infrastructure/sso/OidcProvider";
|
||||||
import { Loader } from "./infrastructure/wrappers/WithPageSuspense";
|
import { Loader } from "./infrastructure/wrappers/WithPageSuspense";
|
||||||
@ -27,7 +27,7 @@ const GlobalStyle = createGlobalStyle`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
root.render(
|
root.render(
|
||||||
<React.StrictMode>
|
<CypressStrictMode>
|
||||||
<GlobalStyle />
|
<GlobalStyle />
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<OidcProvider>
|
<OidcProvider>
|
||||||
@ -36,7 +36,7 @@ root.render(
|
|||||||
</Loader>
|
</Loader>
|
||||||
</OidcProvider>
|
</OidcProvider>
|
||||||
</Provider>
|
</Provider>
|
||||||
</React.StrictMode>,
|
</CypressStrictMode>,
|
||||||
);
|
);
|
||||||
|
|
||||||
// If you want to start measuring performance in your app, pass a function
|
// If you want to start measuring performance in your app, pass a function
|
||||||
|
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>;
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user