Download wp-calypso/client/components/data/query-jetpack-modules/index.jsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/components/data/query-jetpack-modules/index.jsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/components/data/query-jetpack-modules/index.jsx
-
curl -L -o index.jsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/components/data/query-jetpack-modules/index.jsx
1.03 kB
| import PropTypes from 'prop-types'; | |
| import { useEffect } from 'react'; | |
| import { useDispatch } from 'react-redux'; | |
| import { fetchModuleList } from 'calypso/state/jetpack/modules/actions'; | |
| import isFetchingJetpackModules from 'calypso/state/selectors/is-fetching-jetpack-modules'; | |
| import isSiteWpcomAtomic from 'calypso/state/selectors/is-site-wpcom-atomic'; | |
| import { isJetpackSite } from 'calypso/state/sites/selectors'; | |
| const request = ( siteId ) => ( dispatch, getState ) => { | |
| const isJetpack = isJetpackSite( getState(), siteId ); | |
| const isAtomic = isSiteWpcomAtomic( getState(), siteId ); | |
| if ( siteId && ! isFetchingJetpackModules( getState(), siteId ) && ( isAtomic || isJetpack ) ) { | |
| dispatch( fetchModuleList( siteId ) ); | |
| } | |
| }; | |
| function QueryJetpackModules( { siteId } ) { | |
| const dispatch = useDispatch(); | |
| useEffect( () => { | |
| dispatch( request( siteId ) ); | |
| }, [ dispatch, siteId ] ); | |
| return null; | |
| } | |
| QueryJetpackModules.propTypes = { | |
| siteId: PropTypes.number.isRequired, | |
| }; | |
| export default QueryJetpackModules; | |