score:0

class Feed extends React.Component<{ posts: Post[] },{}> {
    private postRefs: Map<number, HTMLInputElement> = new Map<number, HTMLInputElement>();

    render() {
      <div>
         {this.props.posts.map(
          ((post: Post), (index: number)) =>
           <Post
            setRef={(element: HTMLInputElement) => this.postRefs.set(index, element)}
            post={post}
          />)
         }
      </div>
    }

    focusTargetElement() {
      // Does not compile, "Property focus does not exist on Post"
      this.postRefs.get(5).focus();
    }
}

Related Query

More Query from same tag