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.

ListView Selection - setState

See original GitHub issue

Category

[ ] Enhancement

[X ] Bug

[ ] Question

Version

Please specify what version of the library you are using: [v2.4.0]

Expected / Desired Behavior / Question

Expecting selection icons to hold state

Observed Behavior

On selection - calling setState in _getSelection re-renders the selection icons - so they don’t show up as selected - ant cannot be selected again

Steps to Reproduce

Same issue as #11

  private _getSelection = (items: any[]) => {
    console.log('Selected items:', items);
    this.setState({
      selected: true,
    });
  }
<ListView
          key={'main'}
          items={this.state.items}
          viewFields={viewFields}
          compact={true}
          selectionMode={SelectionMode.multiple}
          selection={this._getSelection}
          showFilter={true}
          filterPlaceHolder="Search Policies..."
          dragDropFiles={true}
          onDrop={this._getDropFiles}
          stickyHeader={true} />

Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jaxnzcommented, Mar 8, 2021

Sorry for the late reply, I can confirm updating to the beta fixed the issue.

1reaction
AJIXuMuKcommented, Feb 20, 2021

Hi @jaxnz,

I cannot reproduce the issue using the code you’ve provided. listview-selection.zip

If you are controlling the items/selection state from your component you can also try beta version as we were recently fixing some issues with ListView selection.

Read more comments on GitHub >

github_iconTop Results From Across the Web

flutter - Set state for a button in a ListView - Stack Overflow
The plan is to use a loop to create one of these buttons for each of the necessary selection options and then feed...
Read more >
Flutter Select Only Item from List | setState() - YouTube
You will learn how to select only one item from the list. You will use setState to do that. This could be done...
Read more >
How to Get selected items from ListView in React ... - Syncfusion
Single or many items can be selected by users in the ListView component. An API is used to get selected items from the...
Read more >
SetState - - PowerScript Reference - Appeon Documentation
Sets the highlighted state of an item in a list box. SetState is only applicable to a list box control whose MultiSelect property...
Read more >
Flutter - "setState() or markNeedsBuild() called during build ...
[Solved]-Flutter - "setState() or markNeedsBuild() called during build" while selecting item from listview-Flutter · Related Query · More Query from same tag.
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