Sha256: 88adf0e8e828bdfc5a53d64a068ffa918baed18aca86d39acb6e15dbedd80765

Contents?: true

Size: 889 Bytes

Versions: 944

Compression:

Stored size: 889 Bytes

Contents

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

944 entries across 944 versions & 2 rubygems

Version Path
playbook_ui_docs-13.34.1.pre.alpha.pbntr258paginationkitforreact3409 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui-13.34.1.pre.alpha.pbntr258paginationkitforreact3409 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui_docs-13.34.1.pre.alpha.pbntr258paginationkitforreact3404 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui-13.34.1.pre.alpha.pbntr258paginationkitforreact3404 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui_docs-13.34.1.pre.alpha.powerfontsexternal3403 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui-13.34.1.pre.alpha.powerfontsexternal3403 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui_docs-14.0.0 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui-14.0.0 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui_docs-13.34.1.pre.alpha.PLAY14633399 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui-13.34.1.pre.alpha.PLAY14633399 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui_docs-13.34.0.pre.alpha.PLAY14143373 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui-13.34.0.pre.alpha.PLAY14143373 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui_docs-13.34.0.pre.alpha.PLAY14143372 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui-13.34.0.pre.alpha.PLAY14143372 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui_docs-13.34.0.pre.alpha.PLAY14143358 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui-13.34.0.pre.alpha.PLAY14143358 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui_docs-13.34.0.pre.alpha.PLAY14143357 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui-13.34.0.pre.alpha.PLAY14143357 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui_docs-13.33.1.pre.alpha.PLAY14143340 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx
playbook_ui-13.33.1.pre.alpha.PLAY14143340 app/pb_kits/playbook/pb_typeahead/docs/_typeahead_error_state.jsx