react-code-dataset / wp-calypso /client /layout /guided-tours /config-elements /conditional-block.js
react-code-dataset / wp-calypso /client /layout /guided-tours /config-elements /conditional-block.js
Download wp-calypso/client/layout/guided-tours/config-elements/conditional-block.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 432 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/layout/guided-tours/config-elements/conditional-block.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/layout/guided-tours/config-elements/conditional-block.js
-
curl -L -o conditional-block.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/layout/guided-tours/config-elements/conditional-block.js
432 Bytes
| import PropTypes from 'prop-types'; | |
| import { PureComponent } from 'react'; | |
| import { contextTypes } from '../context-types'; | |
| export default class ConditionalBlock extends PureComponent { | |
| static propTypes = { | |
| when: PropTypes.func.isRequired, | |
| }; | |
| static contextTypes = contextTypes; | |
| render() { | |
| const { isValid } = this.context; | |
| if ( ! isValid( this.props.when ) ) { | |
| return null; | |
| } | |
| return this.props.children; | |
| } | |
| } | |