Skip to content

Could you please help to understand the list reordering example code? #1274

@ZenBerry

Description

@ZenBerry

I'm trying to understand every line of this beautiful example: https://codesandbox.io/embed/r5qmj8m6lq
Could you please suggest from where the "index" argument on line 12 is taken?

const fn = (order, down, originalIndex, curIndex, y) => index =>

I've tried console.logging index and it returns this:

0
1
2
3

The index clearly depends on the number of the springs generated, but how exactly does the fn function get the index value?
Thanks a million!

Upd:

By console.logging I've found out that fn(order.current) on line 19 is calling the return function instead of the fn itself, and passes two arguments there. But could you please help to find out where might this behaviour be defined?
I'm just trying to avoid the confusion in the future)

Peace & love!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions