Skip to content

Instantly share code, notes, and snippets.

View kabudu's full-sized avatar

Kamba Abudu kabudu

View GitHub Profile

Remix's useFetcher doesn't return a Promise for any of its methods (like fetcher.submit()) because Remix doesn't want you to explicitly await anything so they can handle things like cancellation for you. Instead, they recommend adding a useEffect and performing whatever logic you need to after the fetcher is in a particular state.

I found using an effect to run some logic after a submission to be too indirect, and there seem to be plenty of cases where you want to submit a form and then perform some other work on the client (sometimes async, like requesting the user's permission for their location), and I'd rather just do that after a submission in the event handler rather than an effect.

So here's a proof of concept hook that wraps Remix's useFetcher and returns a version of submit that is a promise, and resolves with the data from the action:

function useFetcherWithPromise() {
  let resolveRef = useRef();
  let promiseRef = useRef();
@brunneis
brunneis / overlay2-centos.md
Last active July 8, 2021 14:05
Change storage driver to overlay2 on CentOS
  1. systemctl stop docker
  2. Create the file /etc/docker/daemon.json with the following content:
{
  "storage-driver": "overlay2",
  "storage-opts": ["overlay2.override_kernel_check=true"]
}
  1. systemctl start docker
@guillemcanal
guillemcanal / docker-alpine-iconv.md
Created August 9, 2016 13:03
Build the PHP 5 iconv extension from source for Alpine

Build PHP5 iconv extension from source for Alpine

If you plan to use iconv() to transliterate string in you PHP project, please, take this:

FROM alpine:3.4

RUN apk add --update php5-cli wget build-base php5-dev autoconf re2c libtool \
@satyadeepk
satyadeepk / gcloud_install.sh
Last active February 18, 2022 12:21
Jenkins Google Cloud SDK install with auth script
#Ref: https://github.com/circleci/android-cloud-test-lab/blob/master/circle.yml
export DIRECTORY="/var/jenkins_home/GoogleCloudSDK/google-cloud-sdk/bin"
if [ ! -d "$DIRECTORY" ]; then
# Control will enter here if $DIRECTORY doesn't exist.
cd /var/jenkins_home
wget https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.zip -O google-cloud-sdk.zip
unzip -o google-cloud-sdk.zip -d ./GoogleCloudSDK/
./GoogleCloudSDK/google-cloud-sdk/install.sh
@michiel
michiel / cors-nginx.conf
Created July 5, 2011 10:41
Wide-open CORS config for nginx
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#