Sha256: ecd9ef67e68898be4d8ea644b9f6c545412dd7d964e0c86862b5982f592c23da

Contents?: true

Size: 773 Bytes

Versions: 2

Compression:

Stored size: 773 Bytes

Contents

import React, { useEffect, useRef } from 'react'
import { Body, PhoneNumberInput } from '../..'

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

    // 2. Add any event listener to ref.current.inputNode() inside a useEffect hook.
    useEffect(() => {
        ref.current.inputNode().addEventListener("click", () => alert("Clicked!"))
    })

    // 3. Pass the ref to the ref prop.
    return (
        <>
            <Body text="Click the input field below:" />
            <PhoneNumberInput
                id="access-input-element"
                ref={ref}
                {...props}
            />
        </>
    )
}

export default PhoneNumberInputAccessInputElement

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
playbook_ui_docs-12.26.1.pre.alpha.PLAY860PhoneNumInputOptions836 app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_access_input_element.jsx
playbook_ui-12.26.1.pre.alpha.PLAY860PhoneNumInputOptions836 app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_access_input_element.jsx