Examples of a few hooks.
npm install
npm start
import { readFilePrms } from '../utils' | |
import { join } from 'path'; | |
import { fromProgramString, IntCodeState, computeTillStop, pushInput } from '../intcode/index'; | |
import prompt from 'prompt-promise'; | |
type TPrepped = IntCodeState; | |
async function prep(input:string):Promise<TPrepped>{ | |
return fromProgramString(input); | |
} | |
type TPart1 = number |
import { useState, useEffect } from 'react'; | |
import { renderHook } from '@testing-library/react-hooks'; | |
function someHook(){ | |
const [done, setDone] = useState(false); | |
useEffect(():void => { | |
setTimeout(():void => { | |
setDone(true); | |
}, 1000); |
const {Parser} = require('jison'); | |
const parser = new Parser(` | |
/* lexical grammar */ | |
%lex | |
%% | |
\\s+ /* skip whitespace */ | |
"var" return 'VAR' |
module.exports = { | |
preset: 'ts-jest', | |
testEnvironment: 'node', | |
}; |
import { RegionIso, CountryIso } from "./types"; | |
export async function getCountryIsos():Promise<CountryIso[]> { | |
return [ | |
{iso: "US", iso3: "USA", name: "United States"}, | |
{iso: "CA", iso3: "CAN", name: "Canada"}, | |
{iso: 'JP', iso3: 'JPN', name: 'Japan'} | |
] | |
} |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>DOM Events</title> | |
<style> | |
body, * { | |
font-size: 40px; |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<script | |
src="https://code.jquery.com/jquery-3.4.1.js" | |
integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" | |
crossorigin="anonymous"></script> |
import React, {Component} from 'react'; | |
import {render} from 'react-dom'; | |
// class IncrementContainer extends Component { | |
// constructor(props){ | |
// super(props); | |
// this.state = {count: 0}; | |
// this.increment = this.increment.bind(this); | |
// } | |
// increment(){ |
import React from 'react'; | |
export function IncrementerPresenter({count, increment}){ | |
return <div> | |
<button data-pni-testid='increment' onClick={increment}>The Button</button> | |
{ | |
count === 0 ? (<p>The button has not been pressed yet.</p>) | |
: count === 1 ? (<p>The button has been pressed once.</p>) | |
: (<p>The button has been pressed {count} times</p>) | |
} |