Skip to content

Latest commit

 

History

History
45 lines (32 loc) · 1.57 KB

Select.md

File metadata and controls

45 lines (32 loc) · 1.57 KB

Select

User-interactive component.

Select should be wrapped into FormGroup

Public interface

Props

Select contains Picker component from react-native lib. All props for Picker are valid for Select.

Select provide value to Picker by itself, you can't set it manually

Select provide on change to Picker by itself, you can intercept it but you can't take control on value

Select doesn't have onBlur and onFocus events

Also Select (via props) represents FormGroupProvider context from react-formawesome-core package.

Provide own props:

  • options - values that should be rendered in Select as Picker.Item. Required.
  • onErrorStyles - styles that applies after failed validation. Optional.

Example

<Form 
    onSubmit={async (values) => await someRequest(values)}
    validator={new SchemaValidator(ExampleSchema)}
    errorParser={(error) => myCustomParser(error)}
>
    {/* 
        You can provide 'blur' or 'focus' values to `validateOn` prop,
        but it will not take effect, so use 'change' value or function
    */}
    <FormGroup attribute="surname" validateOn="change">
        <Select
            options={[{ value: "java", label: "Java" }, { value: "js", label: "JavaScript" }]}
            onErrorStyles={{ borderColor: "red" }}
        />
    </FormGroup>
</Form>