moretti | 1 day ago | on: Vite 8.0 Is Out
moretti's comments
moretti | 4 years ago | on: MDN Redesign
moretti | 4 years ago | on: macOS Monterey
moretti | 4 years ago | on: GitHub Copilot Generated Insecure Code in 40% of Circumstances During Experiment
moretti | 4 years ago | on: Yarn 3.0
moretti | 4 years ago | on: Valve Steam Deck
moretti | 6 years ago | on: France fines Apple €25M for iOS software that slowed down older iPhones
moretti | 7 years ago | on: Removing jQuery from GitHub.com frontend
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
moretti | 8 years ago | on: How to optimize React applications that use Redux
moretti | 9 years ago | on: How to implement a programming language in JavaScript
moretti | 9 years ago | on: Bublé: a fast, batteries-included ES2015 transpiler
moretti | 10 years ago | on: We Need a New Username System
moretti | 10 years ago | on: Atom text editor 1.4 released
moretti | 10 years ago | on: Show HN: Jsbundler – Bundle npm packages and use them in the browser
moretti | 10 years ago | on: Node.js 5.0 Released
const foo = ({ a = 2, b = 2, c = 3 } = {}) => a * b * c;
const dict = {b: 4, c: 6};
foo(); // 12
foo(dict); // 48moretti | 10 years ago | on: Pivotal Greenplum Database has been open sourced
moretti | 10 years ago | on: React Desktop – React UI Components for OS X El Capitan and Windows 10
> Any application that can be written in JavaScript, will eventually be written in JavaScript
[0]: http://blog.codinghorror.com/the-principle-of-least-power/
moretti | 10 years ago | on: Embed Node.js on any website
moretti | 10 years ago | on: Embed Node.js on any website
How do you specify npm dependencies. Does it "automagically" inspect your `require` statements?