Skip to content

Commit badc4ca

Browse files
fix: 🐛 props.options not updating from outside (#439)
1 parent db3b662 commit badc4ca

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/hooks/use-multi-select.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from "react";
1+
import React, { useEffect, useState } from "react";
22

33
import { ISelectProps, Option } from "../lib/interfaces";
44

@@ -42,6 +42,10 @@ export const MultiSelectProvider = ({
4242
const [options, setOptions] = useState(props.options);
4343
const t = (key) => props.overrideStrings?.[key] || defaultStrings[key];
4444

45+
useEffect(() => {
46+
setOptions(props.options);
47+
}, [props.options]);
48+
4549
return (
4650
<MultiSelectContext.Provider
4751
value={{ t, ...defaultProps, ...props, options, setOptions }}

0 commit comments

Comments
 (0)