react-native-sortable-list icon indicating copy to clipboard operation
react-native-sortable-list copied to clipboard

Need Example of how to implement ToggleRowActive

Open Metroidaron opened this issue 5 years ago • 5 comments

I would assume that when I include the prop manuallyActivateRows={true} a new value would be passed in the renderRow object; I do not know how to access the toggleRowActive function that is now available because I specified manuallyActivateRows as true.

My RenderRow value is a function that returns a JSX.Element, not a component, and that function also has this bound to the current component. Unsure if that bit is important.

Metroidaron avatar May 16 '19 16:05 Metroidaron

When I Set manuallActivateRows to true, I still don't see any toggleRowActive function as an argument.

vikramkh avatar Dec 19 '19 09:12 vikramkh

Same issue.

mattschaff avatar Jan 12 '20 16:01 mattschaff

Same here!!!

ltsharma avatar Feb 01 '20 10:02 ltsharma

Same issue.

sohnhyunji avatar Feb 27 '20 06:02 sohnhyunji

This worked for me:

Pass in toggleRowActive explicitly to your renderRow component:

<SortableList
    data={listItems}
    renderRow={({ active, data, toggleRowActive }) => (
      <Row active={active} data={data} toggleRowActive={toggleRowActive} />
    )}
    manuallyActivateRows={true}
/>

Use it in the renderRow component:

const Row = ({ data, active, toggleRowActive }) => {
  return (
    <View style={{flexDirection: 'row', justifyContent: 'space-between'}}>
      <Text>{data.description}</Text>
      {/* This is the handle */}
      <TouchableOpacity onPressIn={() => toggleRowActive()}>
        <Text>#</Text>
      </TouchableOpacity>
    </View>
  )
}

dperrera avatar May 25 '20 20:05 dperrera