You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello
I'm trying to get element from the DOM and set it's text content, I managed to make it work, but the way I did it doesn't seem right to me
const getElement = id => IO(() => document.querySelector(id))
const setElementText = element => text => IO(() => element.textContent = text)
getElement('h1').map(setElementText).run()('New Title').run() // it works
I am calling "run()" twice and I believe it should be called once. Btw I know I can just swap argument position in "setElementText" function so I accept "text" first then "element" then I would be able to call "run()" once and it would work. But I am interested is there a better solution for example above.
The text was updated successfully, but these errors were encountered:
Hello
I'm trying to get element from the DOM and set it's text content, I managed to make it work, but the way I did it doesn't seem right to me
I am calling "run()" twice and I believe it should be called once. Btw I know I can just swap argument position in "setElementText" function so I accept "text" first then "element" then I would be able to call "run()" once and it would work. But I am interested is there a better solution for example above.
The text was updated successfully, but these errors were encountered: