Skip to content

Instantly share code, notes, and snippets.

const initialState = {
password: '',
confirmPassword: ''
};
const [form, setForm] = useState(initialState);
const [errorMessage, setErrorMessage] = useState(initialState);
<TextField
onChange={evt => onFormChange('password', evt.target.value)}
value={form.password}
helperText={errorMessage.password || ''}
/>
const onFormChange = (fieldName, value) => {
const newForm = { …form };
newForm[fieldName] = value;
newErrorMessage = getNewErrorMessage(newForm);
setForm(newForm);
setErrorMessage(newErrorMessage);
};
newForm = {
password: "p",
confirmPassword: ""
}
newErrorMessage = {
password: "Panjang password minimal 8 karakter dengan gabungan huruf dan angka",
confirmPassword: "Konfirmasi Password baru tidak boleh kosong"
}
{
"development": {
"username": "root",
"password": "password",
"database": "database_development",
"host": "127.0.0.1",
"dialect": "mysql",
"operatorsAliases": false
},
"test": {
@aabccd021
aabccd021 / .bashrc
Created February 11, 2021 09:41
basic bashrc
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
export PATH="$PATH":"$HOME/snap/flutter/common/flutter/.pub-cache/bin"
export PATH="$PATH:$(yarn global bin)"
export DENO_INSTALL="/$HOME/.deno"
export PATH="$DENO_INSTALL/bin:$PATH"
@aabccd021
aabccd021 / solid.tsx
Created September 6, 2021 11:59
solid js discriminated union control flow
import { render } from "solid-js/web";
import { createSignal, createEffect } from "solid-js";
type Option<T> =
| {
_tag: "Some";
value: T;
}
| {
_tag: "None";
fd --extension .ts --exec sed -i -z 's/{\n/{/g' {} \; && fd --extension .ts --exec sed -i -z 's/\[\n/\[/g' {} \; && fd --extension .ts --exec sed -i -z 's/(\n/(/g' {} \; && pnpm lint:fix
@aabccd021
aabccd021 / htmlToReadable.ts
Created January 3, 2024 12:15
convert `@worker-tools/html` `HTML` to node.js `Response`
export function htmlToReadable(html: HTML): Readable {
const asyncIterator = html[Symbol.asyncIterator]();
return new Readable({
objectMode: false,
read: async function() {
const {value, done} = await asyncIterator.next();
if (done) {
this.push(null);