Skip to content

Instantly share code, notes, and snippets.

View npverni's full-sized avatar

Nathan Verni npverni

  • Tropic
  • 56th and Wabasha
View GitHub Profile
@npverni
npverni / useDebounce-demo.js
Created May 22, 2020 14:22
useDebounce hook with useState and useEffect
// import useDebounce
import { useDebounce } from './hooks';
// store searchTerm in state
const [searchTerm, setSearchTerm] = useState('search');
// setup a debounced version of searchTerm
const debouncedSearchTerm = useDebounce(pricePointSearchTerm, 500);
@npverni
npverni / margarita.md
Last active May 15, 2020 19:40 — forked from moklett/margarita.md
The Perfect Margarita

The Perfect Margarita

This is my "go to" margarita because of the ease of preparation and the simplicity of ingredients.

TL;DR

1oz orange liqueur, 2oz tequila, 3oz limeade, 1/2 lime, shaken with ice.

@npverni
npverni / App.js
Last active January 16, 2023 23:24
useConnector: A custom hook that enables a redux-like setup with action creators using useReducer under the hood
import React from 'react';
import useConnector from './useConnector';
import reducer from './reducer';
import * as unboundActions from './actions';
const App = () => {
const initialState = { count: 0 };
const [state, actions] = useConnector(initialState, reducer, unboundActions);
@npverni
npverni / customers.json
Created August 8, 2018 12:10
Customers.json
[
{
name: "Mike James",
email: "mike@example.com",
},
{
name: "Sue Jones",
email: "sue@example.com",
},
{
import React, { Component } from 'react';
import './App.css';
class App extends Component {
state = {
focused: '',
}
setFocus = field => this.setState({ focused: field });
unsetFocus = () => console.log("Unsetting focus");
isFocused = field => (this.state.focused === field);
@npverni
npverni / es6-stateless-functional-implicit.js
Last active January 14, 2017 17:49
Creating a Stateless Functional React component with implicit return
const Profile = props =>
<div>
<h1>{props.name}</h1>
<p>{props.bio}</p>
</div>;
@npverni
npverni / es6-stateless-functional.js
Last active January 14, 2017 17:40
Creating a Stateless Functional React Component
const Profile = ({ name, bio }) =>
<div>
<h1>{name}</h1>
<p>{bio}</p>
</div>;
@npverni
npverni / es6-class.js
Created January 14, 2017 16:44
Creating a React Component using ES6 React.Component
class Profile extends React.Component {
render() {
return(
<div>
<h1>{this.props.name}</h1>
<p>
{this.props.bio}
</p>
</div>
);
@npverni
npverni / es5.js
Created January 14, 2017 16:27
Creating a React Component using ES5 React.createClass
var Profile = React.createClass({
render: function() {
return (
<div>
<h1>{this.props.name}</h1>
<p>{this.props.bio}</p>
</div>
);
}
});
@npverni
npverni / pokedex.js
Last active November 17, 2016 17:21
[
{
number: 1,
name: 'Bulbasaur',
types: ['Grass', 'Poison'],
description: "Bulbasaur can be seen napping in bright sunlight. There is a seed on its back. By soaking up the sun's rays, the seed grows progressively larger.",
evolvesFrom: null,
evolvesInto: 2,
},
{