Skip to content

Instantly share code, notes, and snippets.

@indreklasn
Created December 17, 2019 12:13
Show Gist options
  • Save indreklasn/0c4d2bdd5d209e4379ad764a7499e4fc to your computer and use it in GitHub Desktop.
Save indreklasn/0c4d2bdd5d209e4379ad764a7499e4fc to your computer and use it in GitHub Desktop.
import React, { memo } from 'react'
import { Icon } from 'antd'
const NoteList = memo(({data, onRemove, onEdit}) => (
<>
{data && data.map(note => (
<div key={note.ref.id} className="note-row">
<p
contentEditable
suppressContentEditableWarning
onChange={e => onEdit(e, note.ref.id, e.currentTarget.textContent)}
onBlur={e => onEdit(e, note.ref.id, e.currentTarget.textContent)}
onInput={e => onEdit(e, note.ref.id, e.currentTarget.textContent)}
>
{note.data.text}
</p>
<Icon
onClick={(e) => onRemove(e, note.ref.id)}
theme="twoTone" style={{ cursor: "pointer", fontSize: '16px'}}
type="delete"
/>
</div>
))}
</>
))
export default NoteList;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment