Download spectrum/src/components/conditionalWrap/index.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 552 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/src/components/conditionalWrap/index.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/spectrum/src/components/conditionalWrap/index.js
-
curl -L -o index.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/src/components/conditionalWrap/index.js
552 Bytes
| // @flow | |
| // Conditionally wrap a Component in some more JSX | |
| // | |
| // Usage: | |
| // <ConditionalWrap | |
| // condition={shouldLink} | |
| // wrap={children => <TouchableOpacity onPress={this.onPress}>{children}</TouchableOpacity>} | |
| // > | |
| // <OtherComponent /> | |
| // </ConditionalWrap> | |
| import type { Node } from 'react'; | |
| type Props = { | |
| condition: boolean, | |
| wrap: (children: Node) => *, | |
| children: Node, | |
| }; | |
| function ConditionalWrap({ condition, wrap, children }: Props) { | |
| return condition ? wrap(children) : children; | |
| } | |
| export default ConditionalWrap; | |