CodePudding user response:
And the selected item is an object not a string value:
const handlePostChange = (options) => {
const postArray = [];
options.map((option) => {
if (option.value == 'select_all') {
postValues = postValues.splice(1, (postValues.length - 1));
postValues.map((option) => postArray.push(option));
} else {
postArray.push(option);
}
});
setState({
post_id: postArray,
});
};
CodePudding user response:
You forgot the value prop
<Select
options={postValues}
placeholder={"Select Post"}
className="modal__input"
isMulti={true}
name={"post_id"}
onChange={handlePostChange}
value={state.post_id}
/>