-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(notification): include displayname wrapper to prevent enzyme sele…
…ctor failure (#8863) * fix(notification): include displayname wrapper to prevent enzyme test selector failure * fix(structuredlist): add displayname wrappers for v11 export switch * feat(project): add custom component creator for next/classic variants Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
57a2307
commit 5f9ae2a
Showing
8 changed files
with
152 additions
and
120 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
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,30 @@ | ||
/** | ||
* Copyright IBM Corp. 2016, 2018 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { useFeatureFlag } from '../components/FeatureFlags'; | ||
|
||
export function createComponentToggle(spec) { | ||
const { name, flag = 'enable-v11-release', next, classic } = spec; | ||
|
||
function ComponentToggle(props, ref) { | ||
const enabled = useFeatureFlag(flag); | ||
if (enabled) { | ||
if (next) { | ||
return React.createElement(next, { ...props, ref: ref }); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
return React.createElement(classic, { ...props, ref: ref }); | ||
} | ||
|
||
ComponentToggle.displayName = `FeatureToggle(${name})`; | ||
|
||
return React.forwardRef(ComponentToggle); | ||
} |