Sha256: 46ae0be32300bfb6275836db8b754e0f2f5713100ddd8263cc160d533c27a13c

Contents?: true

Size: 899 Bytes

Versions: 821

Compression:

Stored size: 899 Bytes

Contents

// @flow

import React, { useState, useEffect } from 'react'

import Typeahead from '../_typeahead'

const options = [
  { label: 'Orange', value: '#FFA500' },
  { label: 'Red', value: '#FF0000' },
  { label: 'Green', value: '#00FF00' },
  { label: 'Blue', value: '#0000FF' },
]

const TypeaheadErrorState = (props) => {
  const [errorState, setErrorState] = useState("Please make a valid selection");
  const [searchValue, setSearchValue] = useState(null);
  
  const handleOnChange = (value) => setSearchValue(value)

    useEffect(() => {
      if(searchValue) {
        setErrorState("")
      } else {
        setErrorState("Please make a valid selection")
      }
    }, [searchValue])
  
  return (
    <Typeahead
        error={errorState}
        label="Colors"
        onChange={handleOnChange}
        options={options}
        {...props}
    />
  )
}

export default TypeaheadErrorState

Version data entries

821 entries across 821 versions & 2 rubygems

Version Path
playbook_ui_docs-13.30.0.pre.alpha.play1367contenttagnoninputkits3159 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui-13.30.0.pre.alpha.play1367contenttagnoninputkits3159 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui_docs-13.30.0.pre.alpha.20240515remotebuildkitconversion3150 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui-13.30.0.pre.alpha.20240515remotebuildkitconversion3150 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui_docs-13.30.0.pre.alpha.PBNTR353draggablev53136 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui-13.30.0.pre.alpha.PBNTR353draggablev53136 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui_docs-13.30.0.pre.alpha.PLAY1328fixtimelinekitglobalpropsreact3096 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui-13.30.0.pre.alpha.PLAY1328fixtimelinekitglobalpropsreact3096 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui-13.30.0 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui_docs-13.29.0.pre.alpha.removeduplicatekitexampleclass3063 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui-13.29.0.pre.alpha.removeduplicatekitexampleclass3063 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui_docs-13.29.0.pre.alpha.PBNTR329draggablev33060 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui-13.29.0.pre.alpha.PBNTR329draggablev33060 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui_docs-13.29.0.pre.alpha.PBNTR329draggablev33059 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui-13.29.0.pre.alpha.PBNTR329draggablev33059 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui_docs-13.29.0.pre.alpha.testingcollapsibleissue3052 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui-13.29.0.pre.alpha.testingcollapsibleissue3052 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui-13.29.0 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui_docs-13.28.0.pre.alpha.PBNTR297gradientoverlay3029 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui-13.28.0.pre.alpha.PBNTR297gradientoverlay3029 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx