Since Twitter doesn't have an edit button, it's a suitable host for JavaScript modules.
Source tweet: https://twitter.com/rauchg/status/712799807073419264
const leftPad = await requireFromTwitter('712799807073419264');
Since Twitter doesn't have an edit button, it's a suitable host for JavaScript modules.
Source tweet: https://twitter.com/rauchg/status/712799807073419264
const leftPad = await requireFromTwitter('712799807073419264');
Tether is a great library for positioning stuff (tooltips, modals, hints, etc) in your web app.
But, as I use React, it was pretty problematic for me, as Tether mutates the DOM and React breaks miserably when it sees mutated DOM. The solution is to have the tethered element outside the part of the DOM tree which is controlled by React (in this case, I use document.body
).
That's why I created 2 helpers to use Tether with React.
The first one, TetheredElement
is a plain JS helper to create a new element, attach it to some other one via Tether, and populate it with some React component.
The second one, TetherTarget
is a React component and it uses TetheredElement
to integrate it further with React, so that you can attach components to each other with Tether, without leaving the cozy React/JSX world and worrying about manual DOM operations. Just write:
Here's how to make your site not load CSS and/or JS in IE older than 11:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=8,9,11">
<title>Page title</title>
<!--[if !IE]>-->
Hi Nicholas,
I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I led the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:
The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can't
When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:
const Article = require('../../../../app/models/article');
Those suck for maintenance and they're ugly.
const varRegex = /:([a-zA-Z][a-zA-Z0-9]*)/g; | |
function Route(template) { | |
this.pack = function pack(data) { | |
const varRegexClone = new RegExp(varRegex); | |
return template.replace(varRegex, function (m) { | |
const key = varRegexClone.exec(m)[1]; | |
varRegexClone.lastIndex = 0; // resetting regex object | |
return data[key]; | |
}); | |
}; |