Fixed forward reference issue caused by new Antd version.

This commit is contained in:
Patrick Fic
2020-07-15 11:12:30 -07:00
parent 09990b1642
commit bdd1f53ff9
3 changed files with 23 additions and 31 deletions

View File

@@ -1,17 +1,13 @@
import { Select } from "antd";
import React, { useEffect, useState } from "react";
import React, { useEffect, useState, forwardRef } from "react";
const { Option } = Select;
//To be used as a form element only.
const JobSearchSelect = ({
value,
onChange,
options,
onBlur,
disabled,
loading,
}) => {
const JobSearchSelect = (
{ value, onChange, options, onBlur, disabled, loading },
ref
) => {
const [option, setOption] = useState(value);
useEffect(() => {
@@ -22,6 +18,7 @@ const JobSearchSelect = ({
return (
<Select
ref={ref}
disabled={disabled}
showSearch
autoFocus
@@ -31,9 +28,8 @@ const JobSearchSelect = ({
}}
loading={loading}
onChange={setOption}
optionFilterProp="children"
onBlur={onBlur}
>
optionFilterProp='children'
onBlur={onBlur}>
{options
? options.map((o) => (
<Option key={o.id} value={o.id}>
@@ -48,4 +44,4 @@ const JobSearchSelect = ({
</Select>
);
};
export default JobSearchSelect;
export default forwardRef(JobSearchSelect);