Sha256: 5be62adae432db3e77d3da02a6d999191835d8dcb0c879fc1fc817f1b99a194b

Contents?: true

Size: 728 Bytes

Versions: 673

Compression:

Stored size: 728 Bytes

Contents

import React, { useRef } from 'react'
import { Button, PhoneNumberInput } from 'playbook-ui'

const PhoneNumberInputClearField = (props) => {
    // 1. Create a ref - this accesses the kit's input element.
    const ref = useRef()

    // 2. Use clearField() to clear the field.
    const handleClick = () => {
        ref.current.clearField()
    }

    // 3. Pass the ref to the ref prop.
    return (
        <>
            <PhoneNumberInput
                id="clear-field"
                ref={ref}
                {...props}
            />

            <Button
                onClick={handleClick}
                text="Clear the Input Field"
            />
        </>
    )
}

export default PhoneNumberInputClearField

Version data entries

673 entries across 673 versions & 2 rubygems

Version Path
playbook_ui_docs-14.8.0.pre.alpha.PLAY1649rolloutheightglobalprops4635 app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_clear_field.jsx
playbook_ui-14.8.0.pre.alpha.PLAY1649rolloutheightglobalprops4635 app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_clear_field.jsx
playbook_ui_docs-14.9.0.pre.rc.8 app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_clear_field.jsx
playbook_ui-14.9.0.pre.rc.8 app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_clear_field.jsx
playbook_ui_docs-14.8.0.pre.alpha.PLAY1598floatinguiupgrade4617 app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_clear_field.jsx
playbook_ui-14.8.0.pre.alpha.PLAY1598floatinguiupgrade4617 app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_clear_field.jsx
playbook_ui_docs-14.9.0.pre.rc.7 app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_clear_field.jsx
playbook_ui-14.9.0.pre.rc.7 app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_clear_field.jsx
playbook_ui_docs-14.9.0.pre.rc.6 app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_clear_field.jsx
playbook_ui-14.9.0.pre.rc.6 app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_clear_field.jsx
playbook_ui_docs-14.9.0.pre.rc.5 app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_clear_field.jsx
playbook_ui-14.9.0.pre.rc.5 app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_clear_field.jsx
playbook_ui_docs-14.8.0.pre.alpha.pbntr661createstickyleftprop4612 app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_clear_field.jsx
playbook_ui-14.8.0.pre.alpha.pbntr661createstickyleftprop4612 app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_clear_field.jsx
playbook_ui_docs-14.8.0.pre.alpha.play1648heightglobalprops4606 app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_clear_field.jsx
playbook_ui-14.8.0.pre.alpha.play1648heightglobalprops4606 app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_clear_field.jsx
playbook_ui_docs-14.9.0.pre.rc.4 app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_clear_field.jsx
playbook_ui-14.9.0.pre.rc.4 app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_clear_field.jsx
playbook_ui_docs-14.9.0.pre.rc.3 app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_clear_field.jsx
playbook_ui-14.9.0.pre.rc.3 app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_clear_field.jsx