Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

21
  • 3
    How do you achieve this on stateless components? Commented Apr 17, 2016 at 15:04
  • 4
    Stateless (function) components don't have this, so there's nothing to bind. Usually the methods are supplied by a wrapper smart component. Commented Apr 17, 2016 at 15:06
  • 57
    @OriDrori: How does that work when you need to pass data in the callback? onClick={() => { onTodoClick(todo.id) } Commented May 12, 2016 at 20:14
  • 6
    @adam-beck - add it inside the callback method definition in the class cb() { onTodoClick(this.props.todo.id); }. Commented May 12, 2016 at 22:54
  • 2
    @adam-beck I think this is how to use useCallback with dynamic value. stackoverflow.com/questions/55006061/… Commented Aug 24, 2019 at 4:13