Skip to content

Instantly share code, notes, and snippets.

View Jaikant's full-sized avatar
👋

jknt Jaikant

👋
View GitHub Profile
@Jaikant
Jaikant / web.js
Last active November 10, 2023 07:21
web.js
function cloneProps(props) {
const propKeys = Object.keys(props);
return propKeys.reduce((memo, k) => {
const prop = props[k];
memo[k] = Object.assign({}, prop);
if (isObject(prop.value) && !isFunction(prop.value) && !Array.isArray(prop.value)) memo[k].value = Object.assign({}, prop.value);
if (Array.isArray(prop.value)) memo[k].value = prop.value.slice(0);
return memo;
}, {});
}
@Jaikant
Jaikant / gist:b13fac1ed431b5d14f0738aa79b337df
Created August 10, 2018 01:52
Function components to class components
<!DOCTYPE html>
<html>
<head>
<title>First React App</title>
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script src='https://unpkg.com/babel-standalone@6/babel.min.js'></script>
</head>
<body>
<div id='app'></div>
@Jaikant
Jaikant / index7.html
Created August 9, 2018 17:04
React Simple Functional Components
<!DOCTYPE html>
<html>
<head>
<title>First React App</title>
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script src='https://unpkg.com/babel-standalone@6/babel.min.js'></script>
</head>
<body>
<div id='app'></div>
@Jaikant
Jaikant / gist:eeb9f15ffcadfc9024f6c94a97e2e365
Created April 24, 2018 06:30
Formspree with React/Gatsby Example
/* eslint-disable no-undef, react/prop-types */
import React from 'react';
import { css } from 'react-emotion';
import { Box, Flex } from '../../components/Layout';
import colors from '../../utils/colors';
import ButtonPrimary from '../../components/Buttons';
const input = css`
display: block;
box-sizing: border-box;
@Jaikant
Jaikant / webpack.config.js
Last active January 9, 2018 08:08
Minimum webpack.config.js from running sharp with nodejs
const webpack = require('webpack')
var fs = require('fs');
var nodeModules = {};
fs.readdirSync('node_modules')
.filter(function(x) {
return ['.bin'].indexOf(x) === -1;
})
.forEach(function(mod) {
nodeModules[mod] = 'commonjs ' + mod;