Skip to content

Instantly share code, notes, and snippets.

// File: UseLocalStorageTextInput.tsx
// Author: Mitch Allen
import {ChangeEventHandler, useCallback, useState} from "react";
export interface LocalStorageTextInput {
storageKey?: string,
id?: string,
name?: string,
label?: string,
// File: UseTextInput.tsx
// Author: Mitch Allen
import {ChangeEventHandler, useCallback, useState} from "react";
export interface TextInput {
id?: string,
name?: string,
label?: string,
helperText?: string,
// File: UsedCheckedInput.tsx
// Author: Mitch Allen
import {ChangeEventHandler, useCallback, useState} from "react";
export interface CheckedInput {
id?: string,
name?: string,
init?: boolean,
}
@mitchallen
mitchallen / index-test.js
Created December 16, 2021 03:40
How to Create a JavaScript Module (NodeJS, Browser) (scriptable.com)
// Add this to the bottom of index.js
let robbie = makeObject();
robbie.hello();
let b9 = makeObject({ name: 'B9' });
b9.hello();
@mitchallen
mitchallen / index-import.js
Created December 16, 2021 03:37
How to Create a JavaScript Module (NodeJS, Browser) (scriptable.com)
// Modify the index.js import command:
import {makeObject, default as obj} from './my-mod.js';
@mitchallen
mitchallen / my-mod-make-object.js
Last active December 16, 2021 16:32
How to Create a JavaScript Module (NodeJS, Browser) (scriptable.com)
// Insert into my-mod.js above default export
export function makeObject(options = {}) {
let {
name = 'Robbie'
} = options;
function hello() {
console.log(`My name is ${name}`);
}
@mitchallen
mitchallen / index.html
Created December 16, 2021 03:30
How to Create a JavaScript Module (NodeJS, Browser) (scriptable.com)
<html>
<head>
<title>js-module-01</title>
</head>
<body>
<script type="module" src="./index.js"></script>
</body>
</html>
@mitchallen
mitchallen / package.json
Last active December 16, 2021 16:35
How to Create a JavaScript Module (NodeJS, Browser) (scriptable.com)
{
"name":"js-module-01",
"version":"1.0.0",
"description":"",
"type":"module",
"main":"index.js",
"scripts":{
"test":"echo \"Error: no test specified\" && exit 1"
},
"keywords":[
@mitchallen
mitchallen / index.js
Last active December 16, 2021 03:25
How to Create a JavaScript Module (NodeJS, Browser) (scriptable.com)
// File: index.js
// Author: Mitch Allen
import obj from './my-mod.js';
obj.name = "Droid";
console.log( "My name is", obj.name );
@mitchallen
mitchallen / my-mod.js
Created December 16, 2021 03:22
How to Create a JavaScript Module (NodeJS, Browser) (scriptable.com)
// File: my-mod.js
// Author: Mitch Allen
export default {}