-
Notifications
You must be signed in to change notification settings - Fork 837
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EuiProvider] Add a check and dev warning+early return for nested usa…
…ge (#6949) * [setup] DRY out warning logic and write more robust unit tests for it * [cleanup] Move `EuiThemeProvider` nested tests to theme provider file - they don't really belong in `EuiProvider` * [cleanup] Improve EuiThemeProvider's unit testing - make `EuiProvider`s tests more basic in comparison - use `toHaveStyleRule` instead of snapshots * [cleanup] Convert more EuiProvider tests to RTL from Enzyme * [cleanup] Convert `EuiProvider` cache tests to RTL from Enzyme * Set up a context to check for nested `EuiProvider`s * Update `EuiProvider` to return early and emit a warning if nested usage is detected * Fix types on EuiProvider's props table * [docs] Improve `EuiProvider` and `EuiThemeProvider` docs - clarify in as many places as possible - remove uncertain language (e.g. 'currently', 'future') that were still not yet figured out when docs were written - try to remove overlap in docs between provider and theme provider, try to clarify nested usage of theme provider - add examples to warning section * changelog * Fix Cypress tests failing due to nested EuiProviders * [PR feedback] Allow `cy.mount` to have a configurable provider props
- Loading branch information
Showing
20 changed files
with
691 additions
and
3,252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
|
||
import { EuiCodeBlock } from '../../../../src'; | ||
|
||
export default () => { | ||
return ( | ||
<> | ||
<EuiCodeBlock language="jsx" fontSize="m" isCopyable> | ||
{`import { setEuiDevProviderWarning } from '@elastic/eui'; | ||
setEuiDevProviderWarning('warn');`} | ||
</EuiCodeBlock> | ||
|
||
<p>Examples of apps that would cause warnings:</p> | ||
|
||
<EuiCodeBlock language="jsx" fontSize="m" isCopyable> | ||
{`const AppWithMissingProvider = () => ( | ||
<EuiPageTemplate> | ||
{/* Will render, but will warn about missing EuiProvider */} | ||
</EuiPageTemplate> | ||
); | ||
const App = () => ( | ||
<EuiProvider> | ||
{/* Content */} | ||
</EuiProvider> | ||
); | ||
const AppWithDuplicateProvider = () => ( | ||
<EuiProvider> | ||
{/* Will warn about multiple providers */} | ||
<App /> | ||
</EuiProvider> | ||
)`} | ||
</EuiCodeBlock> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.