λΈλ¬μ λν μ λ ₯μ μ§μ°λ λ°©λ²μ΄ μμΌλ©΄ μ’μ κ²μ λλ€.
μ΄λ refλ₯Ό μ λ ₯μ μ λ¬ν μ μκ±°λ clearInputOnDeleteμ μ μ¬ν μ μνμ ν΅ν΄ μνν μ μμ΅λλ€.
λ΄ μ¬μ© μ¬λ‘μ μλ μ΄μ λ λ΄κ° κ³ μ λ μ μ μΈνΈλ₯Ό μ λ¬νκ³ μ¬μ©μκ° μ μκ³Ό μΌμΉνμ§ μλ κ²μ μ λ ₯νλ©΄ μ λ ₯μ μ΄μ μ νλ¦¬κ² νκ³ μ λ ₯μ΄ μ ν¨ν κ²μ²λΌ 보μ΄κΈ° λλ¬Έμ λλ€. μ μ§ λ. μΌμΉνμ§ μλ ν μ€νΈ νλͺ©μ μ μ§λμ§ μλλ€λ μ μ λΆλͺ ν νκ³ μΆμ΅λλ€.
μ΄ κ΅¬μ± μμμ v6μ μ¬μ©νλ κ²μ 보μμ΅λκΉ?
https://github.com/i-like-robots/react-tags/tree/6.0
μ΄ λ²μ μλ onBlur
μ½λ°±κ³Ό .clearInput()
λ©μλκ° λͺ¨λ μμ΅λλ€ π
λ©μ§! λλ₯Ό μν΄ κ·Έκ²μ ν΄κ²° π
@i-like-robots μ΄μ λν΄ λ€μ λ
Όνμ ν΄μ μ£μ‘ν©λλ€λ§ ν¨ν€μ§μ μν΄ λ
ΈμΆλ μ°Έμ‘°κ° μκΈ° λλ¬Έμ clearInput()
λ©μλμ μ‘μΈμ€νλ λ°©λ²μ λν΄ λμκ² λΆλΆλͺ
ν©λκΉ? μΌλ°μ μΌλ‘ this.reactTagsRef.current.clearInput()
μ κ°μ κ²μ μ¬μ©νμ¬ μ΄μ κ°μ μμ λ©μλμ μ‘μΈμ€ν©λλ€.
μ΄ λ¦¬ν¬μ§ν 리μ μμ λ₯Ό μ¬μ©νκ³ onBlur
μ½λ°±μΌλ‘ νμ₯νμ¬ κ΅¬μ± μμμ μΈμ€ν΄μ€μ ref
λ₯Ό μΆκ°ν©λλ€.
class App extends React.Component {
constructor (props) {
super(props)
this.state = {
tags: [],
suggestions: []
}
+ this.reactTags = React.createRef()
}
onDelete (i) {
const tags = this.state.tags.slice(0)
tags.splice(i, 1)
this.setState({ tags })
}
onAddition (tag) {
const tags = [].concat(this.state.tags, tag)
this.setState({ tags })
}
+ onBlur () {
+ if (this.reactTags.current) {
+ this.reactTags.current.clearInput()
+ }
+ }
render () {
return (
<ReactTags
+ ref={this.reactTags}
tags={this.state.tags}
suggestions={this.state.suggestions}
+ onBlur={this.onBlur.bind(this)}
onDelete={this.onDelete.bind(this)}
onAddition={this.onAddition.bind(this)}
/>
)
}
}
μλ²½ν©λλ€. κ°μ¬ν©λλ€!