|
Download wp-calypso/packages/data-stores/src/user/README.md from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 500 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/data-stores/src/user/README.md
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/packages/data-stores/src/user/README.md
-
curl -L -o README.md https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/data-stores/src/user/README.md
500 Bytes
| # User store | |
| This store includes behavior for checking if a user is logged in, and fetching info about the current user. | |
| ## Usage | |
| Register the user store: | |
| ```js | |
| import { User } from '@automattic/data-stores'; | |
| const USER_STORE = User.register(); | |
| ``` | |
| ### Current user | |
| Check if a current user is logged in: | |
| ```js | |
| import { useSelect } from '@wordpress/data'; | |
| function MyComponent() { | |
| const isLoggedIn = useSelect( ( select ) => select( USER_STORE ).isCurrentUserLoggedIn() ); | |
| // …snip | |
| } | |
| ``` | |