Skip to content

Instantly share code, notes, and snippets.

View flarnie's full-sized avatar

Flarnie Marchan flarnie

View GitHub Profile
let React = require('react');
var ReactTestUtils = require('react-dom/test-utils');
class TextWithStringRef extends React.Component {
render() {
return (
<span ref="foo">
Hello world!
</span>
);
@flarnie
flarnie / deprecating_unused_create_mixin_helper.md
Created May 24, 2017 16:58
More information about the deprecation of the unused `React.createMixin` helper

React.createMixin was never implemented

The React.createMixin helper was never actually implemented - the code for it simply took a mixin as an argument and returned it with no changes:

  createMixin: function(mixin) {
    // Currently a noop. Will be used to validate and trace mixins.
 return mixin;
@flarnie
flarnie / unknown-prop-warning-v15.6-fixture.html
Created April 21, 2017 18:32
fixture used to test the deduping of unknown prop warning in React v15.6
<!DOCTYPE html>
<html style="width: 100%; height: 100%; overflow: hidden">
<head>
<meta charset="utf-8">
<title>Unknown Props Example</title>
</head>
<body>
<h1>Unknown Props Example</h1>
<div id="container">
<p>
@flarnie
flarnie / ReactWaypoint.js
Created March 27, 2015 18:39
build/ReactWaypoint.js
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
@flarnie
flarnie / infinite-scroll-example-style.css
Created February 21, 2015 23:34
React-Waypoint Styling the Scrollable Parent
.infinite-scroll-example__scrollable-parent {
height: 500px;
overflow-y: scroll;
position: relative;
}
@flarnie
flarnie / infinite-scroll-example-step-3.jsx
Last active August 29, 2015 14:15
React-Waypoint Infinite Scroll Step 3
var InfiniteScrollExample = React.createClass({
_loadMoreItems: function() {
this.setState({ loading: true });
// Do the fetching of data here with AJAX
// In this fake example we just generate more image urls
// and set the state of 'loading' to false.
// ...
},
getInitialState: function() {
@flarnie
flarnie / infinite-scroll-example-step-2.jsx
Last active May 21, 2016 15:38
React-Waypoint Infinite Scroll Step 2
var InfiniteScrollExample = React.createClass({
//...
_renderItems: function() {
return this.state.items.map(function(imageUrl, index) {
// ... generate list items here ...
});
},
_renderWaypoint: function() {
if (!this.state.isLoading) {
@flarnie
flarnie / gist:5cb7f7166399fe43e367
Created February 21, 2015 22:41
Installing React-Waypoint
// npm
> npm install react-waypoint --save
// bower
> bower install react-waypoint --save
@flarnie
flarnie / webpack.config.js
Created January 1, 2015 17:38
Basic Webpack Config
/* global __dirname */
var webpack = require('webpack');
module.exports = {
// for every key under 'entry', a JS file will be built
entry: {
bundle: './src/main.js.jsx'
},
output: {
path: __dirname + '/public/javascripts',
filename: '[name].js'
@flarnie
flarnie / ThreadSection.react.js
Created December 9, 2014 00:57
Flux ChatApp Sample 2
// Looking at the 'componentDidMount' will usually show
// whic stores this component listens to.
// ...
function getStateFromStores() {
return {
threads: ThreadStore.getAllChrono(),
currentThreadID: ThreadStore.getCurrentID(),
unreadCount: UnreadThreadStore.getCount()
};
}