Skip to content

Instantly share code, notes, and snippets.

View httpJunkie's full-sized avatar
🏠
Working from home

Eric Bishard httpJunkie

🏠
Working from home
View GitHub Profile
@httpJunkie
httpJunkie / useWindowSizeWithDebounce.js
Last active August 14, 2020 13:16
useWindowSizeWithDebounce
import { useEffect, useState } from 'react';
const debounce = (delay: number, fn: any) => {
let timerId: any;
return function (...args: any[]) {
if (timerId) {
clearTimeout(timerId);
}
@httpJunkie
httpJunkie / useWindowDimensions.js
Created November 5, 2019 18:59
useWindowDimensions
function useWindowDimensions() {
// set our default for the state to the curent width and height
const [width, setWidth] = React.useState(window.innerWidth)
const [height, setHeight] = React.useState(window.innerHeight)
// constantly update our state as the window is resized
React.useEffect(() => {
const listenenr = () => {
setWidth(window.innerWidth)
/* These changes to the Todo.js file, and the todoReducer.js file */
/* Can be applied to the following git commit to build the Todo App with Reducer logic */
/*
coomit: 5e7d1ae9ac2d2943c088799ac902063f1ba38c9a
repo: https://github.com/httpJunkie/react-todo
*/
/* #Step 01: Add useReducer, initial state and useRef hooks */
import { todoReducer } from './todoReducer';
@httpJunkie
httpJunkie / useLocalStorageState.js
Last active May 14, 2020 11:00
useLocalStorageState
/* https://stackblitz.com/edit/use-local-storage-state */
function useLocalStorageState(key, defaultValue) {
const [state, setState] = useState(() => {
let value
try {
value = JSON.parse(
window.localStorage.getItem('my-app-count') || JSON.stringify(defaultValue)
)
} catch (e) {
@httpJunkie
httpJunkie / .gitignore
Created November 30, 2018 19:52
Basic JavaScript git ignore file
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
# testing
/coverage
# production
/build
import React from 'react';
export default class SmartContainerComponent extends React.Component {
constructor() {
super()
this.state = {
products: [
{ name: "Winged Fighter", productCode: "XJ1000" },
{ name: "R2D2", productCode: "r2Dee2" }
]
@httpJunkie
httpJunkie / Kendo Sales Dashboard - GridData
Created October 15, 2018 21:06
Kendo Sales Dashboard - GridData
export const gridData = [
{
"ProductID": 1,
"ProductName": "Chai",
"SupplierID": 1,
"CategoryID": 1,
"QuantityPerUnit": "10 boxes x 20 bags",
"UnitPrice": 18,
"UnitsInStock": 39,
"UnitsOnOrder": 0,
@httpJunkie
httpJunkie / KSD_PanelBarContainer_v1
Last active March 10, 2019 01:18
Kendo Sales Dashboard - PanelBarContainer v1
import React from 'react';
import { PanelBar, PanelBarItem } from '@progress/kendo-react-layout';
import { panelBarData } from '../data/appData';
const imageUrl = (imageName) => ('img/'+ imageName +'.jpg');
export const PanelBarContainer = () => (
<PanelBar >
<PanelBarItem expanded={true} title="My Teammates">
<div>
@httpJunkie
httpJunkie / KSD_AppCss_v2
Last active October 17, 2018 21:16
Kendo Sales Dashboard - Second Update to App.css
.teammate:after {
content: ".";
display: block;
height: 0;
line-height: 0;
clear: both;
visibility: hidden;
}
.teammate h2 {
font-size: 1.3em;