moretti's comments

moretti | 1 day ago | on: Vite 8.0 Is Out

Thanks to the Vite team for building a faster, modern bundling solution on a fully open source stack that isn't tied to a specific framework...cough cough, Turbopack

moretti | 4 years ago | on: MDN Redesign

It looked okay until I scrolled down to the browser compatibility table and had to tilt my head to read the vertical text

moretti | 4 years ago | on: macOS Monterey

Can anyone confirm if the final build number is the same as 12.0.1 RC2 (21A559)? You can run `$ sw_vers` from the CLI to check it.

moretti | 4 years ago | on: Yarn 3.0

yarn 2 solved real problems with zero install and advanced PnP. Maybe the only problem was that it was released too early, wasn't mature enough when it came out. Now it's just better than v1 and npm, works particularly well on large mono repos where upgrading a package can often break other modules due to how node_modules hoisting works.

moretti | 7 years ago | on: Removing jQuery from GitHub.com frontend

By declaratively I mean that in React you typically declare how an element should be render given the current (props, [state]).

For example, in vanilla JS, you might have something like:

  const btn = document.createElement('button');
  btn.className = 'btn red';
  btn.onclick = function(event) {
   if (this.classList.contains('red')) {
     this.classList.remove('red');
     this.classList.add('blue');
   } else {
     this.classList.remove('blue');
     this.classList.add('red');
   }
  };

In React instead:

  class Button extends React.Component {
    state = { color: 'red' }
    handleChange = () => {
      const color = this.state.color === 'red' ? 'blue' : 'red';
      this.setState({ color });
    }
    render() {
      return (<div>
        <button 
           className=`btn ${this.state.color}`
           onClick={this.handleChange}>
        </button>
      </div>);
    }
  }
I find it simpler to understand, because render, given its state, describes exactly how the UI should be.

moretti | 7 years ago | on: Removing jQuery from GitHub.com frontend

It’s interesting that you find this “simpler”. One of the great advantages of React is that is declarative, it’s easy to understand how a component will render given a set of (props, state). Your example is quite the opposite, the render method violates this principle and each event handler manipulates the DOM using a ref. I’d call this spaghetti-React.

moretti | 10 years ago | on: Node.js 5.0 Released

You still have to simulate named arguments with an object:

    const foo = ({ a = 2, b = 2, c = 3 } = {}) => a * b * c;
    const dict = {b: 4, c: 6};

    foo(); // 12
    foo(dict); // 48

moretti | 10 years ago | on: Embed Node.js on any website

Embed CSS on any website! ;-)

How do you specify npm dependencies. Does it "automagically" inspect your `require` statements?

page 1