Skip to content

Instantly share code, notes, and snippets.

View dan-codes-16's full-sized avatar

Dan Codes dan-codes-16

View GitHub Profile
// This is an example of how to fetch external data in response to updated props,
// If you are using an async mechanism that does not support cancellation (e.g. a Promise).
class ExampleComponent extends React.Component {
_currentId = null;
state = {
externalData: null
};
import { PropTypes, Children } from 'react';
import classNames from 'classnames';
/**
* Defines whether it's server or client side rendering environment (can use DOM client side)
*
* @type {Boolean}
*/
const canUseDOM = !!(
typeof window !== 'undefined' &&
@dan-codes-16
dan-codes-16 / isInputDateSupported.js
Created April 6, 2015 12:28
Checks if html5 input type date is supported
'use strict';
module.exports = {
/**
* Checks if html5 input date is supported
*
* @return {Boolean} True if html5 input date is supported by the client browser
*/
isInputDateSupported: function () {
var el = document.createElement('input'),
@dan-codes-16
dan-codes-16 / mirror.css
Created April 1, 2015 06:26
Mirror page :)
body {
-moz-transform: scaleX(-1);
-o-transform: scaleX(-1);
-webkit-transform: scaleX(-1);
transform: scaleX(-1);
filter: FlipH;
-ms-filter: "FlipH";
transform: rotateY(180deg);
}
@dan-codes-16
dan-codes-16 / ismobile.js
Created March 18, 2015 06:35
Check if mobile from JavaScript
'use strict';
module.exports = {
/**
* Checks for iOs, Android, Blackberry, Opera Mini, and Windows mobile devices
* Based on http://www.detectmobilebrowsers.com
*
* @return {Boolean} True if user agent is mobile
*/
isMobile: function() {