DEV Community

artydev
artydev

Posted on

Why I use MVU ?

Again, MVU is a lighter version of DML with some addons.

I like using MVU because of all the niceties I can write.

Suppose you want a function which allows to insert variable lines break in your component.

Here is how to accomplish this with MVU (Javascript :-))

const {dom, udom, m, render } = MVU;

let div  = m("div")
let br = m("br")
let hr = m("hr")
let nbr = (n = 1) => [...Array(n)].map(br)

function MyComponent () {
  let view = dom() // we wrap our component in a div
    div("I am followed by one line break")
    nbr()
    hr()
    div("I am followed by 5 lines break")
    nbr(5)
    hr()
  udom() // enf of wrapping
  return view
}

render(app, MyComponent())
Enter fullscreen mode Exit fullscreen mode

You can test it here : NBR

Top comments (2)

Collapse
 
mellen profile image
Matt Ellen-Tsivintzeli

Your DML link links to the node.js home page

Collapse
 
artydev profile image
artydev

Corrected, thank you very much :-)