Skip to content

Commit

Permalink
[#365] Fix Cannot read length property in Storybook error
Browse files Browse the repository at this point in the history
  • Loading branch information
palagdan committed Oct 22, 2024
1 parent cbbae1f commit 9802c73
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/components/answer/TypeaheadAnswer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { IntelligentTreeSelect } from "intelligent-tree-select/lib/components/In
import "intelligent-tree-select/lib/styles.css";

const processTypeaheadOptions = (options, intl) => {
if (!options || !options.length) {
if (options === undefined || !options.length) {
return [];
}

Expand All @@ -41,9 +41,9 @@ const TypeaheadAnswer = (props) => {
const intl = configurationContext.options.intl;

const [isLoading, setLoading] = useState(true);
const [optionsList, setOptionsList] = useState([
processTypeaheadOptions(props.options, intl),
]);
const [optionsList, setOptionsList] = useState(
processTypeaheadOptions(props.options, intl)
);

useEffect(() => {
let isCancelled = false;
Expand Down Expand Up @@ -79,7 +79,7 @@ const TypeaheadAnswer = (props) => {
return () => {
isCancelled = true;
};
}, []);
}, [queryHash, formGenContext, props.question, intl]);

const generateTreeOptions = (possibleValues) => {
if (!possibleValues) {
Expand Down Expand Up @@ -169,8 +169,7 @@ const TypeaheadAnswer = (props) => {
? noLinksValueRenderer
: null
}
valueIsControlled={true}
value={optionsList.filter((option) => option.id === props.value)}
value={optionsList.find((option) => option.id === props.value) || null}
multi={false}
options={optionsList}
isSearchable={true}
Expand Down

0 comments on commit 9802c73

Please sign in to comment.