Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrei Daniliuk adaniliuk

  • United States
View GitHub Profile
View updating-external-data-when-props-changes-using-promises.js
// 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
};
View page.js
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' &&
@adaniliuk
adaniliuk / isInputDateSupported.js
Created Apr 6, 2015
Checks if html5 input type date is supported
View isInputDateSupported.js
'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'),
View mirror.css
body {
-moz-transform: scaleX(-1);
-o-transform: scaleX(-1);
-webkit-transform: scaleX(-1);
transform: scaleX(-1);
filter: FlipH;
-ms-filter: "FlipH";
transform: rotateY(180deg);
}
@adaniliuk
adaniliuk / ismobile.js
Created Mar 18, 2015
Check if mobile from JavaScript
View ismobile.js
'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() {