rafaelmotta / react-native-tag-select

🏷 A simple tag component to act as radio button / checkbox
156 stars 43 forks source link

How to toggle itemsSelected on maxSelected #7

Open Rana-Muhammad-Amir opened 6 years ago

Rana-Muhammad-Amir commented 6 years ago

Hey..! i want to toggle value of this.tag.itemsSelected on selection more than one value. Simply i mean that if a user select one item and then he selecte the other one the item should automatically toggle and only second value should be selected.

thanks in advance.....

7laria commented 6 years ago

same issue

7laria commented 6 years ago

i create a workaround changing the handleSelectItem of TabSelect.js ` handleSelectItem = (item) => { const key = item[this.props.keyAttr] || item

const value = []
const found = this.state.value[key]

// Item is on array, so user is removing the selection
// if (found) {
//   delete value[key]
// } else {
//   // User is adding but has reached the max number permitted
//   if (this.props.max && this.totalSelected >= this.props.max) {
//     if (this.props.onMaxError) {
//       return this.props.onMaxError()
//     }
//   }

//  
// }
value[key] = item
return this.setState({ value }, () => {
  if (this.props.onItemPress) {
    this.props.onItemPress(item)
  }
})

}`