-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNote.js
31 lines (23 loc) · 805 Bytes
/
Note.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import React, { Component } from 'react'
class Note extends Component{
componentWillReceiveProps(nextProps) {
const newProps = nextProps
this.textInput.value = newProps.note.heading
this.textAreaInput.value = newProps.note.value
}
save = (note) => {
note.heading = this.textInput.value
note.value = this.textAreaInput.value
this.props.savenote(note)
}
render(){
const { note } = this.props
return(
<div className='note-wrapper-single'>
<input defaultValue={ note.heading } type='text' placeholder='Untitled' ref={(input) => { this.textInput = input }} onChange={(event)=>this.save(note) }/>
<textarea defaultValue={ note.value } ref={(input) => { this.textAreaInput = input}} onChange={()=>this.save(note) }/>
</div>
)
}
}
export default Note