Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

基础组件用 Function Component,会导致 ref 使用受限 #33

Closed
Darmody opened this issue Aug 1, 2019 · 2 comments · Fixed by #56
Closed

基础组件用 Function Component,会导致 ref 使用受限 #33

Darmody opened this issue Aug 1, 2019 · 2 comments · Fixed by #56

Comments

@Darmody
Copy link
Contributor

Darmody commented Aug 1, 2019

ref 传递 function 失效

<Input
  className="add-todo-input"
  placeholder="What needs to be done?"
  onInput={e => setText(e.detail.value)}
  focus={undefined}
  ref={container => {
    this.input = container;
  }}
  value={text}
/>

屏幕快照 2019-08-01 23 57 08

@yesmeck
Copy link
Member

yesmeck commented Aug 2, 2019

加 forwardRef 就可以了。

@Darmody
Copy link
Contributor Author

Darmody commented Aug 6, 2019

屏幕快照 2019-08-06 23 08 12

forwardRef 会报错

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants