Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function binding only passes the first argument #91

Open
wise-danya opened this issue Oct 2, 2024 · 1 comment
Open

Function binding only passes the first argument #91

wise-danya opened this issue Oct 2, 2024 · 1 comment
Labels
question Further information is requested

Comments

@wise-danya
Copy link

Description

I'm encountering a situation where using reflect to bind a function with multiple arguments only seems to pass the first argument. I'd like to clarify if this is the intended behaviour.

Current Implementation

import { reflect } from "@effector/reflect"

const View = ({ onClick }: { onClick: (first: string, second: number, third: boolean) => void }) => (
  <button onClick={() => onClick("first", 1, true)}>Test</button>
)

const Demo = reflect({
  view: View,
  bind: {
    onClick: (first, second, third) => {
      console.log("onClick", first, second, third)
      // Logs: "onClick", "first", undefined, undefined
    },
  },
})

Current Behaviour

When calling the bound function with multiple arguments, only the first argument is received:

onClick "first" undefined undefined

Additional Context

  • @effector/reflect: 9.2.0
  • effector: 23.2.3
  • effector-react: 23.2.1
  • react: 18

Question

Is this the expected behavior for binding functions with multiple arguments?
Any clarification would be greatly appreciated. Thank you!

@zerobias
Copy link
Member

zerobias commented Oct 7, 2024

Reflect functionality based on scopeBind, which initially was created for binding events and effects, and as they could only have one argument this feature was also applied to scopeBind with function too. There is no reason to keep this restriction on plain function, so we can remove it. Thanks for report, we overlooked this case!
Probably will be added in next minor or major effector release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants