-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Options does not update from state/props for functional components #134
Comments
ChangeToPosts and ChangeToUsers never return |
@sanusart I looked up previous issues and tried to implement your example inside a functional component |
https://codesandbox.io/s/epic-herschel-194rp?file=/src/App.js |
@sanusart So i downgraded to 4.5.1 for now. Please do check for 4.6.1. And thanks for the prompt replies. |
Yes. regression was introduced in 4.6.0. #133 Thanks. Latest version with no issue 4.5.2 |
…ing in the search bar, #134, #133 (#136) * Working searchFn example. * Remove debug code. * Undo indentation * Restore changes. * Remove debug code. * Restore return. * Add test for a custom function. * Add test coverage for custom search function. * Apply code review suggestions. * Reset searchResults on blur. * Clear search results on dropdown; update search results on options change.
* master: (27 commits) v4.7.0 See changelog: https://github.com/sanusart/react-dropdown-select/blob/master/CHANGELOG.md FIX (searchFn)[#101] searchFn callback should only call once when typing in the search bar, #134, #133 (#136) 4.6.1 Revert "FIX (searchFn)[#101] searchFn callback should only call once when typing in the search bar (#131)" (#135) v4.6.0 See changelog: https://github.com/sanusart/react-dropdown-select/blob/master/CHANGELOG.md FIX (searchFn)[#101] searchFn callback should only call once when typing in the search bar (#131) v4.5.2 See changelog: https://github.com/sanusart/react-dropdown-select/blob/master/CHANGELOG.md FIX (style): Accepts a short color (#127) v4.5.1 See changelog: https://github.com/sanusart/react-dropdown-select/blob/master/CHANGELOG.md FIX (duplicates)[#116]: more proper way to check dupes, closes #116 FIX (duplicates): PR comments FIX (duplicates)[#116]: more proper way to check dupes, closes #116 bump version v4.5.0 See changelog: https://github.com/sanusart/react-dropdown-select/blob/master/CHANGELOG.md FIX (input) [#114]: fix chars truncated, closes #114 v4.4.2 See changelog: https://github.com/sanusart/react-dropdown-select/blob/master/CHANGELOG.md FIX (box-model): add box-sizing border-box, closes #94 (#104) Bump websocket-extensions from 0.1.3 to 0.1.4 (#102) DOCS (example): add import to example, thanks to @karland, closes #93 CHORE (types): fix keepOpen type | closes #95 (#96) ... # Conflicts: # __tests__/__snapshots__/index.spec.js.snap # __tests__/components/__snapshots__/DropdownHandle.spec.js.snap # package-lock.json # src/components/DropdownHandle.js
import React, { useState, useEffect } from "react";
import Select from "react-dropdown-select";
const Try = () => {
const [options, setOptions] = useState([]);
const [loadedNow, setLoadedNow] = useState("users");
useEffect(() => {
changeToUsers();
}, []);
const changeToPosts = () => {
const result = [
{ title: "Post1", desc: "post1 description" },
{ title: "Post2", desc: "post2 description" },
];
setOptions(
result.map((post) => ({
label: post.title,
value: post.desc,
}))
);
setLoadedNow("posts");
};
const changeToUsers = () => {
const result = [
{ username: "Abhay", email: "abhay@gmail.co" },
{ username: "Ajay", email: "ajay@gmail.co" },
];
setOptions(
result.map((user) => ({
label: user.username,
value: user.email,
}))
);
setLoadedNow("users");
};
return (
<div style={{ padding: "1rem", background: "#fff" }}>
<h1>Try page</h1>
<hr />
<br />
<div>
<p>Hello | {loadedNow} loaded</p>
{loadedNow === "users" && (
<button onClick={changeToPosts}>change to posts</button>
)}
{loadedNow === "posts" && (
<button onClick={changeToUsers}>change to users</button>
)}
</div>
<Select
placeholder="Type to search"
multi
// loading={this.state.loading}
onChange={() => undefined}
values={[]}
keepOpen
options={options}
/>
</div>
);
};
export default Try;
Not working. Please provide solution
The text was updated successfully, but these errors were encountered: