mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-31 06:52:50 +08:00
♻️ Change hook props from object to argument list
This commit is contained in:
parent
c6d7875fda
commit
d28f4f0784
2 changed files with 5 additions and 6 deletions
|
@ -21,7 +21,7 @@ const Accordion = ( {
|
|||
children = null,
|
||||
className = '',
|
||||
} ) => {
|
||||
const { isOpen, toggleOpen } = useToggleState( { id, initiallyOpen } );
|
||||
const { isOpen, toggleOpen } = useToggleState( id, initiallyOpen );
|
||||
const wrapperClasses = classNames( 'ppcp-r-accordion', className, {
|
||||
'ppcp--is-open': isOpen,
|
||||
} );
|
||||
|
|
|
@ -14,13 +14,12 @@ const determineInitialState = ( id, initiallyOpen ) => {
|
|||
/**
|
||||
* Allows managing a toggle-able component, such as an accordion or a modal dialog.
|
||||
*
|
||||
* @param {Object} props
|
||||
* @param {string} props.id - Optional, if provided, the toggle can be opened via the URL.
|
||||
* @param {null|boolean} props.initiallyOpen - Optional. If provided, it defines the initial open state.
|
||||
* If omitted, the initial open state is determined by using the "id" logic (inspecting the URL).
|
||||
* @param {string} [id=''] - If provided, the toggle can be opened via the URL.
|
||||
* @param {null|boolean} [initiallyOpen=null] - If provided, it defines the initial open state.
|
||||
* If omitted, the initial open state is determined by using the "id" logic (inspecting the URL).
|
||||
* @return {{isOpen: unknown, toggleOpen: (function(*): boolean)}} Hook object.
|
||||
*/
|
||||
export function useToggleState( { id = '', initiallyOpen = null } ) {
|
||||
export function useToggleState( id = '', initiallyOpen = null ) {
|
||||
const [ isOpen, setIsOpen ] = useState(
|
||||
determineInitialState( id, initiallyOpen )
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue