Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Mohan Dere mohandere

🎯
Focusing
Block or report user

Report or block mohandere

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mohandere
mohandere / sortObject.js
Last active Dec 20, 2018
Sort plain js object based on custom order from Array
View sortObject.js
// Example -
// { category: 'Cloths', 'brand': 'Van H', collection: 'New' }.sortObject(['brand', 'category', 'collection']);
var sortingBasedOnArr = ['collection', 'brand', 'category'];
var targetObject = { category: 'Cloths', 'brand': 'Van H', collection: 'New' }
Object.prototype.sortObject = function(sortingArr) {
var targetObj = this;
var result = {}
if (!targetObj) {
return result;
@mohandere
mohandere / registerServiceWorker.js
Created Aug 10, 2018
Service worker working example
View registerServiceWorker.js
// Main service worker controller
function ServiceWorkerController() {
this._toastsView = new ToastsView();
this._register();
};
ServiceWorkerController.prototype._register = function() {
if (!navigator.serviceWorker) return;
var ServiceWorkerController = this;
var swUrl = "/${optportalName}/service-worker/service-worker.js";
@mohandere
mohandere / package.json
Created May 30, 2018
package.json - Obfuscate CSS class names in Create React App without eject
View package.json
{
"name": "my-react-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"babel-plugin-react-css-modules": "^3.4.2",
"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-scripts": "1.1.4"
},
@mohandere
mohandere / config-overrides.js
Created May 30, 2018
config-overrides.js - Obfuscate CSS class names in Create React App without eject
View config-overrides.js
// File - src/config-overrides.js
// react-app-rewired: Override create-react-app webpack configs without ejecting
const path = require("path");
const { compose, getLoader, injectBabelPlugin } = require("react-app-rewired");
function rewire(config, env) {
const cssRules = getLoader(
@mohandere
mohandere / App.js
Created May 30, 2018
App.js - Obfuscate CSS class names in Create React App without eject
View App.js
// File - src/App.js
import React, { Component } from 'react';
import logo from './logo.svg';
import Link from './Link';
import styles from './App.css';
class App extends Component {
render() {
return (
<div className={styles.App}>
@mohandere
mohandere / App.css
Last active May 30, 2018
App.css - Obfuscate CSS class names in Create React App without eject
View App.css
// File - src/App.css
.App {
text-align: center;
}
.AppLogo {
height: 80px;
}
View SettingsForm.js
import React, { Component } from 'react';
import{
Grid, Row, Col,
FormGroup, ControlLabel
} from 'react-bootstrap';
import { Field, reduxForm } from 'redux-form'
import { renderInputField, required, email } from 'utils/form-helpers'
let SettingsForm = props => {
const { handleSubmit, submitting } = props
@mohandere
mohandere / asyncRoutes.js
Created Mar 11, 2018
asyncRoutes in CRA
View asyncRoutes.js
import React from 'react';
import {
Route,
Switch
} from 'react-router';
import Loadable from 'react-loadable';
import AppLoader from './common/components/AppLoader';
// Import modules/routes
import About from './about';
@mohandere
mohandere / App.js
Last active Mar 11, 2018
Code Splitting - dynamic import
View App.js
import React, { Component } from 'react';
class App extends Component {
handleClick = () => {
import ('./moduleA')
.then(({
moduleA
}) => {
// Use moduleA
})
@mohandere
mohandere / epicGetUserRepos.js
Last active Feb 19, 2018
Epic get github user repos
View epicGetUserRepos.js
import { ajax } from 'rxjs/observable/dom/ajax';
import 'rxjs/add/operator/catch'
import {
REQUEST_USER_REPOS_START
} from '../actions/actionTypes';
import {
doUserReposFulfilled,
doUserReposFailed
} from '../actions/doUserRepos';
You can’t perform that action at this time.