Skip to content
Discussion options

You must be logged in to vote

In such as case I suggest that you use the "controlled" sortable component. After each reorder of items you should update the state to reflect the actual order of items. Then you could reset to the initial state by setting the initial data array in state.

Consider this example:

const INITIAL_DATA = <your data array>;

function YourComponent() {
  const [data, setData] = useState(INITIAL_DATA);
  
  const reset = () => {
    setData(INITIAL_DATA)
  }
  
  <Sortable.Grid
    data={data}
    renderItem={renderItem}
    columns={1}
    // You can use the onDragEnd callback to update the state after each re-ordering
    // (see: https://react-native-sortables-docs.vercel.app/grid/props#ondragend)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tasugi
Comment options

Answer selected by tasugi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants