Package

purescript-react-select-basic

Repository
lumihq/purescript-react-select-basic
License
Apache-2.0
Uploaded by
spicydonuts
Published on
2018-08-15

react-basic bindings for react-select

Build Status

Docs

Available on Pursuit

Example

module Example where

import Prelude

import Data.Maybe (Maybe(Nothing), maybe)
import Data.Nullable (toMaybe)
import Effect.Uncurried (mkEffectFn1)
import React.Basic (ReactComponent, createElement, react)
import React.Basic.ReactSelect (singleSelect)

component :: ReactComponent {}
component = react { displayName: "BasicExample", initialState, receiveProps, render }
  where
    initialState =
      { selectedValue: Nothing
      }

    receiveProps _ _ _ =
      pure unit

    render _ state setState =
      createElement singleSelect
        { value: maybe "" _.value state.selectedValue
        , options
        , onChange: mkEffectFn1 $ \newValue ->
            setState _ { selectedValue = toMaybe newValue }
        }

    options =
      [ { label: "A"
        , value: "a"
        }
      , { label: "B"
        , value: "b"
        }
      , { label: "C"
        , value: "c"
        }
      ]