react-code-dataset / wp-calypso /client /components /data /query-jetpack-credentials-status /index.jsx
react-code-dataset / wp-calypso /client /components /data /query-jetpack-credentials-status /index.jsx
Download wp-calypso/client/components/data/query-jetpack-credentials-status/index.jsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 976 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/components/data/query-jetpack-credentials-status/index.jsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/components/data/query-jetpack-credentials-status/index.jsx
-
curl -L -o index.jsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/components/data/query-jetpack-credentials-status/index.jsx
976 Bytes
| import PropTypes from 'prop-types'; | |
| import { useEffect } from 'react'; | |
| import { useDispatch } from 'react-redux'; | |
| import { testCredentials } from 'calypso/state/jetpack/credentials/actions'; | |
| import { | |
| hasJetpackCredentials, | |
| isRequestingJetpackCredentialsTest, | |
| } from 'calypso/state/jetpack/credentials/selectors'; | |
| const request = ( siteId, role ) => ( dispatch, getState ) => { | |
| const hasCredentials = hasJetpackCredentials( getState(), siteId, role ); | |
| if ( hasCredentials && ! isRequestingJetpackCredentialsTest( getState(), siteId, role ) ) { | |
| dispatch( testCredentials( siteId, role ) ); | |
| } | |
| }; | |
| function QueryJetpackCredentialsStatus( { siteId, role } ) { | |
| const dispatch = useDispatch(); | |
| useEffect( () => { | |
| dispatch( request( siteId, role ) ); | |
| }, [ dispatch, siteId, role ] ); | |
| return null; | |
| } | |
| QueryJetpackCredentialsStatus.propTypes = { | |
| siteId: PropTypes.number.isRequired, | |
| role: PropTypes.string.isRequired, | |
| }; | |
| export default QueryJetpackCredentialsStatus; | |