diff --git a/package.json b/package.json index 9110d42..6936748 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,10 @@ "classnames": "^2.3.1", "lodash": "^4.17.21" }, + "peerDependencies": { + "react": ">=16.8", + "react-dom": ">=16.8" + }, "devDependencies": { "@babel/cli": "7.14.3", "@babel/core": "^7.14.3", diff --git a/src/Dropdown.tsx b/src/Dropdown.tsx index b9f74c1..940a281 100644 --- a/src/Dropdown.tsx +++ b/src/Dropdown.tsx @@ -1,10 +1,4 @@ -import React, { - useCallback, - useEffect, - useState, - useRef, - useMemo, -} from 'react'; +import React, { useCallback, useEffect, useState, useRef } from 'react'; import classNames from 'classnames'; import get from 'lodash/get'; @@ -42,11 +36,8 @@ export const Dropdown: React.FC = ({ clearIcon, isClearable, }) => { - const options = useMemo( - () => prepareOptions(originalOptions), - [originalOptions], - ); - const [selected, setSelected] = useState( + const options = prepareOptions(originalOptions); + const [selected, setSelected] = useState(() => findSelected(options, value, matcher), ); const [isOpen, setIsOpen] = useState(false); diff --git a/src/Selection.tsx b/src/Selection.tsx index 8dc88f1..f99550d 100644 --- a/src/Selection.tsx +++ b/src/Selection.tsx @@ -1,4 +1,4 @@ -import React, { useState, useMemo } from 'react'; +import React, { useState } from 'react'; import classNames from 'classnames'; import get from 'lodash/get'; @@ -19,11 +19,8 @@ export const Selection: React.FC = ({ noOptionsDisplay, menu: MenuContainer, }) => { - const options = useMemo( - () => prepareOptions(originalOptions), - [originalOptions], - ); - const [selected, setSelected] = useState( + const options = prepareOptions(originalOptions); + const [selected, setSelected] = useState(() => findSelected(options, value, matcher), );