@andru
Living in the woods making things from code and pixels.
I publish a wiki about plants and their many uses, Practical Plants; am working on an app to help people learn and and organise their garden, Hortomatic; I contribute to and maintain some open source projects.
I work with MediaWiki often, and I have a lot of love for Javascript ES2015.
Nothing here yet.
No blogs yet.
React doesn't offer solutions for all DOM events, so sometime's you need to reach out to the DOM and attach an event listener yourself. Just make sure you add it in componentDidMount and remove it in componentWillUnmount (see "Component Specs and Lifecycle " )... Forgetting the latter will create a memory leak and attach a new listener every time the component is mounted. var Box = React.createClass({ getInitialState: function ( ) { return {windowWidth: window .innerWidth}; }, handleResize: function ( e ) { this .setState({windowWidth: window .innerWidth}); }, componentDidMount: function ( ) { window .addEventListener( 'resize' , this .handleResize); }, componentWillUnmount: function ( ) { window .removeEventListener( 'resize' , this .handleResize); }, render: function ( ) { return < div > Current window width: {this.state.windowWidth} </ div > ; } }); Where you can solve the problem with React's events, you should. It'll save you time and offer a slight performance enhancement (not having to attach and remove handlers). Source: React Docs: "DOM Event Listeners in a Component "
Usually IDM/Breakcore or various other flavours of electronic music. Recently I've been addicted to an awesome album built on sounds from GameBoy circuit-bending: Deidream:AM I've always found a lot of stuff released by Planet Mu (Venetian Snares, Joseph Nothing, Boxcutter, Luke Vibert) to be good for programming sessions. Also, Portico Quartet are amazing for some rhythmic steel drum (handpan) claronet craziness.
Even after so many years coding I usually fall into the same trap: the elation of finally finding the solution to hours of frustration drives me to keep on coding; without the reward of rest and reflection my foggy brain inevitably hits another problem, and I get frustrated and demotivated. It's only then that I finally take a break, and it doesn't feel nearly so good as it would've. One day I'll learn from this.