DEV Community

artydev
artydev

Posted on

1

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 :-)

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay