question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to select multiple values

See original GitHub issue

im having problems when I want to select multiple items. When I select one option they throw me this error: TypeError: Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a Symbol.iterator method.

Anyone know how to solved this problem??

im using the version: “react-native-dropdown-picker”: “^5.1.21” here is what im doing:

export default class Example extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            openCurrencyDropDown: false,
            data: [
                { label: 'Op1', value: "Op1" },
                { label: 'Op2', value: "Op2" },
                { label: 'Op3', value: "Op3" },
                { label: 'Op4', value: "Op4" },
                { label: 'Op5', value: "Op5" },
                { label: 'Op6', value: "Op6" },
            ],
            value: [],
        }
        this.setValue = this.setValue.bind(this);
    }

   setValue(callback) {
        this.setState(state => ({
            value: callback(state.value)
        }));
    }

    render() {
             <DropDownPicker
                   listMode={'MODAL'}
                   multiple={true}
                   min={0}
                   max={5}
                   open={this.state.openCurrencyDropDown}
                   setOpen={this.setOpenCurrencyDropDown}
                   setValue={this.setValue}
                   items={this.state.data}
                   defaultValue={this.state.value}
                />
    }
}

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
hossein-zarecommented, Nov 3, 2021

@kjoonas1 Note that your state variable (value) must be an array []

Follow the official example: https://hossein-zare.github.io/react-native-dropdown-picker-website/docs/usage/#multiple-items

1reaction
hossein-zarecommented, Nov 3, 2021

@kjoonas1 Interesting! setValue’s callback always gets the current value, The value variable isn’t undefined while the value param in the callback is undefined.

setValue(state => {

});

The value doesn’t change until you press an item, There’s something wrong on your side i believe.

I encourage you to try firing the setValue in a useEffect:

export const Selector = ({...}) => {
  useEffect(() => {
    setValue(state => {
      console.log("setValue callback value", state);

      return state;
    });
  }, []);

  ...

Don’t forget to restart your app after the changes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to select multiple options for a multi-select picklist
1. Use an alternative browser · 2. Switch to salesforce classic · 3. Click out of the picklist frame and then select the...
Read more >
Unable to multiple select items in combo box
A strange problem here. I have a combo box (comboBooks) that writes the selected choice to a single line text column in a...
Read more >
2939246 - Unable to Select Multiple Values in Report
Go to Business Analytics · Go to Design Report and search for the effected report · Click on the value help of the...
Read more >
Cannot select multiple values when running a report ... - IBM
To resolve the issue, please follow these steps: Open Cognos admin console. ... Click on drop down next to "System" and select "Set...
Read more >
PowerBI Service - Cannot select multiple items in slicer
Solved: For whatever reason, cannot select multiple items in slicer, regardless whether you use Shift + Click or you use Single Select ->...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found