Skip to content

Instantly share code, notes, and snippets.

@barberdt
barberdt / bad.jsx
Created July 14, 2017 18:42
react-redux
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import MyComponent from '../components/MyComponent';
import { pressed } from '../actions/actionCreators';
function mapStateToProps({ mySelector: { foo } }) {
return { foo };
}
@barberdt
barberdt / index.jsx
Created July 9, 2017 21:58
react-hot-loader
import React from 'react';
import ReactDOM from 'react-dom';
import { AppContainer } from 'react-hot-loader';
import Test from './components/Test';
global.document.addEventListener('DOMContentLoaded', () => {
ReactDOM.render(
<AppContainer>
<Test />
var myController = function() {
// create some event handlers
};
myController.destroy = function() {
// I do not believe you have access to anything declared in the myController function here.
};
@barberdt
barberdt / paging.js
Last active November 19, 2015 16:01
class AttachmentActions {
readPage(pageRecord) {
return AttachmentAPI.readPage(pageRecord)
.then(stuff => this.actions.readPageSuccess(stuff, pageRecord));
}
}
class AttachmentStore {
fetchNextPage() {
let pageRecord = this.getNextPageRecord();
class MyActions {
constructor() {
this.generateActions('loadSuccess', 'loadFailure');
}
load() {
this.dispatch();
asyncLoad()
.then(resp => this.actions.loadSuccess(resp))
const MyFunctionalityComponent = React.createClass({
myFunctionalityMethod() {
// do some functionality
}
render() {
if (isMobile) {
return <MyMobileComponent onInteraction={this.myFunctionalityMethod} />
} else {
return <MyDesktopComponent onInteraction={this.myFunctionalityMethod} />

Testing Mkdown

This is a test

AWHN

@barberdt
barberdt / Notifications Paging Issue Repro Steps
Created May 14, 2012 14:32
Notifications Paging Issue Repro Steps
Notifications Paging Issue Repro Steps:
1. Accumulate enough notifications so that you have more than two 'pages' worth (may also repro with just more than one 'page' worth,
can't remember).
2. Go to your 'Notifications' page.
3. 'X' through all notifications in the current page.
4. Click the 'Next' button (the next logical step if you are trying to delete all existing notifications, IMO at least).
5. Observe that you have now 'skipped' over a page of notifications that you must get to by either reloading the entire 'Notifications' page
or by clicking the 'Previous' button.
@barberdt
barberdt / bugswarm.js
Created January 6, 2012 22:24
Client JavaScript for the BUGswarm demo page.
var participationKey = '<YOUR PARTICIPATION KEY>';
var resourceID = '78179599f104fa8838912daed302ce2169f64971';
var swarmID = '399ed6780318c0a5f9f25c34b2a947657057534c';
SWARM.connect({apikey: participationKey,
resource: resourceID,
swarms: [swarmID],
//callbacks
onconnect:
@barberdt
barberdt / bugswarm.html
Created January 6, 2012 22:14
Markup for the BUGswarm demo page.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>BUGswarm</title>
<script src="http://d1z10qq7obk1ve.cloudfront.net/swarm/swarm-v0.3.2.js" type="text/javascript"></script>
</head>