Package Exports
- @mypreview/unicorn-react-hooks
- @mypreview/unicorn-react-hooks/build/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@mypreview/unicorn-react-hooks) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Unicorn ReactJS Hooks
A collection of ReactJS hooks crafted for the WordPress projects.
Installation
Install the module
npm install @mypreview/unicorn-react-hooks --save
Table of Content
Method | Description |
---|---|
useActiveTab | Maintains and determines the current state of the active tab |
useConditionalRef | Conditionally return an instance of useRef |
useDidMount | This hook mimicks the componentDidMount hook for React |
useDidUpdate | This hook mimicks the componentDidUpdate hook for React |
useFindPostById | Finds the selected post object based on the given post id and maintains the state of change when it happens |
useGetBlockLayout | Retrieves the block support value for the "Layout" settings to be used in the preview |
useGetCurrentPost | Retrieves the current post object given the post ID and post-type |
useGetMediaType | Retrieve media MIME type based on given attachment id |
useGetNodeList | Retrieve list of HTML nodes genearted for each post item |
useGetPostMeta | Retrieves a post meta field of the current post |
useGetPosts | Retrieve a list of post-type posts and refresh the list when any direct arguments change |
useGetProducts | Retrieve a list of product posts and refresh the list when any direct arguments change. |
useGetProductTerms | Retrieve a list of product taxonomy terms and refresh the list when any direct arguments change. |
useGetSiteData | Retrieves the current site data or object |
useGetTerms | Retrieve a list of taxonomy terms and refresh the list when any direct arguments change. |
useInnerBlocksProps | This module merely adds backward compatibility for the usage of experimental useInnerBlocksProps in projects created using WordPress versions prior to 5.9 |
useInputValue | This hook takes an initial value for an input field and updates it when the onChange event raises |
useIsDraggingWithin | This hook determines whether an element is being dragged within another (ref) target element |
useLatLngBounds | Generates latitude & longitude from a given address |
usePostTypeNameRestBase | This hook maintains the state of the post-type name and REST-API base key extraction from the given string value |
usePreparePosts | Determines whether the current WordPress query has posts to loop over, and slices the query according to the maximum limit determined |
useTimeout | A setTimeout hook that calls a callback after a timeout duration |
useToast | This hook allows for generating custom (notification) toast messages |
useToggle | This hook takes a parameter with value and allows for quickly toggling the value |
useUpdatePostMeta | Updates a post meta field based on the given post ID |