Skip to content

[Question] Method call from parent #84

Description

@VanFraecker

I think I misunderstood some fundamental: I want to know, how can I call a method from a child component in a parent component, especially when use it in a list?

{this.items.map((item) => {
  let textRef // does not work
  return (
    <div key={item.id} pointerdown={() => textRef.doSomething()}>
      <Child ref={textRef} />
    </div>
  )
})}

Refs only work with dom nodes.
Store solution with observe (for calling a method) or props with observe are an overkill for a simple method call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions