refactor(examples): enhance update node example

This commit is contained in:
moklick
2020-12-10 12:30:29 +01:00
parent 36025b28b0
commit a64a1239a9
3 changed files with 33 additions and 23 deletions
+4 -10
View File
@@ -25,12 +25,9 @@ const BasicFlow = () => {
setElements((elms) => {
return elms.map((el) => {
if (isNode(el)) {
return {
...el,
position: {
x: Math.random() * 400,
y: Math.random() * 400,
},
el.position = {
x: Math.random() * 400,
y: Math.random() * 400,
};
}
@@ -46,10 +43,7 @@ const BasicFlow = () => {
setElements((elms) => {
return elms.map((el) => {
if (isNode(el)) {
return {
...el,
className: el.className === 'light' ? 'dark' : 'light',
};
el.className = el.className === 'light' ? 'dark' : 'light';
}
return el;