kutlugsahin/react-smooth-dnd

Question about getContainerOptions

juliarvalenti opened this issue · 0 comments

Hello,

First of all, thank you so much for your work on this project. It's been immensely helpful for our team.

We ran into issues using this package directly because we are running React 18.2 and we ran into dependency conflicts with the React 16 version of this repo. Therefore, we've decided to port the components into our own codebase and we'll personally maintain them for our own project. This is fine for us, because the codebase is small.

I did want to make sure that I'm doing my due diligence in understanding how this package functions and I just had a question about this bit of code in Container.tsx:

   ...
      if (typeof prop === 'function') {
        result[optionName] = (...params: any[]) => {
          return (this.props[optionName] as Function)(...params);
        }
   ...

I have never seen this pattern before. Would it be possible to explain what is going regarding function props here? Why is this necessary? Is it because React handles Object/Array/Function prop updates as Pass-by-Reference instead of Pass-by-Value?