keyed every element for efficiency
This commit is contained in:
@@ -15,24 +15,24 @@ const notes = [
|
||||
{id: 'ggg', text: 'Note seven'},
|
||||
{id: 'hhh', text: 'Note eight'}
|
||||
];
|
||||
return m('.app', [
|
||||
m('.top', [
|
||||
m('.top-left', [
|
||||
return m('.app', {key: 'app'}, [
|
||||
m('.top', {key: 'top'}, [
|
||||
m('.top-left', {key: 'top-left'}, [
|
||||
m('button', {key: 'button'}, 'New Note...'),
|
||||
m('input.search', {key: 'search', value: ''}),
|
||||
m('select.sorting', {key: 'sorting'}, [
|
||||
m('option', 'Newest -> Oldest'),
|
||||
m('option', 'Oldest -> Newest')
|
||||
m('option', {key: 'new-old'}, 'Newest -> Oldest'),
|
||||
m('option', {key: 'old-new'}, 'Oldest -> Newest')
|
||||
])
|
||||
]),
|
||||
m('.top-right', [
|
||||
m('.bin-id', bin.id),
|
||||
m('button', 'New Bin...')
|
||||
m('.top-right', {key: 'top-right'}, [
|
||||
m('.bin-id', {key: 'bin-id'}, bin.id),
|
||||
m('button', {key: 'new-bin-button'}, 'New Bin...')
|
||||
])
|
||||
]),
|
||||
m('.main', [
|
||||
m('.main', {key: 'main'}, [
|
||||
m('.notes', notes.map(note =>
|
||||
m(Note, {note})
|
||||
m(Note, {note, key: note.id})
|
||||
))
|
||||
])
|
||||
]);
|
||||
|
||||
@@ -3,8 +3,8 @@ return {
|
||||
view: function(vnode){
|
||||
const {note} = vnode.attrs;
|
||||
return m('.note', [
|
||||
m('.text', note.text),
|
||||
m('button', 'Edit')
|
||||
m('.text', {key: 'text'}, note.text),
|
||||
m('button', {key: 'edit-button'}, 'Edit')
|
||||
]);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user