Don't do this. Just read it


(Ex. Dakull) #1

https://hackernoon.com/how-i-converted-my-react-app-to-vanillajs-and-whether-or-not-it-was-a-terrible-idea-4b14b1b2faff#.3a5sz11hv

tl;dr: after reading it I feel less stupid.


(Eugen) #2

Unul din efectele dezvoltarii unui app in React este ca te forteaza sa gandesti declarativ (nu imperativ).

Declarativ:

import { div, input, button, h1 } from './elements.js'

const view = div(
  h1('Hello'),
  input({ value: 'Typing..', onChange: onChange, type: 'text' }),
  button({ onClick: onSubmit }, 'Send'),
)

Imperativ:

const $div = $('div')
const $input = $('input').val('Typing...').on('change', onChange)
const $button = $('button').text('Send').on('click', onSubmit)
const $h1 = $('h1').text('Hello')

$div.html([ $h1, $input, $button ])

tldr: declarativ vs imperativ

Declarative programming is “the act of programming in languages that conform to the mental model of the developer rather than the operational model of the machine”.


(Ex. Dakull) #3

The irony when jQuery can be seen also as a “monad”: