rafaelmotta / react-native-tag-select

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

How to Refresh the Tags? #12

Open DavidRajPaul opened 5 years ago

DavidRajPaul commented 5 years ago

Reloading the list Does not clear the seleted Tag Item. Is there a way to clear all selected Tags?

himanshuNetsol commented 5 years ago

Do it like this:

<TagSelect data={this.state.categories} value={this.state.preSelectedCategories} ref={(tag) => { this.tag = tag; }} />

On Clear Btn Tap:

_clearAllFeeds = () => { debugger const value = {} this.tag.setState({ value }) }

ankitjaiswal1994 commented 3 years ago

For the folks doing functional programming,

  const ref = useRef<TagSelect>();

          <TagSelect
            ref={ref}
            data={data}
          />

then do this on onClear function of yours:

  ref.current.setState({ value: {} });