• Stars
    star
    164
  • Rank 230,032 (Top 5 %)
  • Language
    TypeScript
  • Created over 3 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿฆ˜Step form built using React Hook Form, Yup, Typescript, and Zustand

React-Hook-Form Stepform

All Contributors

rhf-stepform

Code to observe:

Key Points

Each time submitting, data is stored in FormStore

const onSubmit = (data: StepOneData) => {
  setData({ step: 1, data });
  router.push('/form/step-2');
};

The stored data will be used as a default value on revisit

const { stepOne, setData } = useFormStore();

const methods = useForm({
  mode: 'onTouched',
  resolver: yupResolver(stepOneSchema),
  defaultValues: stepOne || {},
});

Upload Form

The tricky part lies in Upload Form. The data that is originally stored by the input is File object, but if we store it in zustand, it will be transformed into regular object. This will cause an error when we invoke the URL.createObjectURL(file) for the FilePreview.

So we need to invoke it while we get the original File, and store the URL as a new property. In that way, we only invoke it once, and just use the blob url for revisit.

const acceptedFilesPreview = acceptedFiles.map(
  (file: FileWithPreview) =>
    Object.assign(file, {
      preview: URL.createObjectURL(file),
    })
);

Contributors โœจ

Thanks goes to these wonderful people (emoji key):


Theodorus Clarence

๐Ÿ’ป

Muhammad Rizqi Tsani

๐Ÿ’ป

This project follows the all-contributors specification. Contributions of any kind welcome!

More Repositories

1

ts-nextjs-tailwind-starter

๐Ÿ”‹ Next.js + Tailwind CSS + TypeScript starter and boilerplate packed with useful development features
TypeScript
2,919
star
2

theodorusclarence.com

๐Ÿ’  Personal website and blog made using Next.js, TypeScript, Tailwind CSS, MDX Bundler, and Prisma with PostgreSQL
MDX
664
star
3

notiolink

โšก Self-hostable branded link shortener built with Next.js & Notion API
TypeScript
198
star
4

aether-design-system

๐Ÿ”† Aether serves as the building block for some of my team projects.
TypeScript
134
star
5

og

๐Ÿ‡ Open Graph Generator made using @vercel/og for personal use
TypeScript
116
star
6

expansion-pack

๐Ÿ”‹ Useful stack expansion for ts-nextjs-tailwind-starter
TypeScript
102
star
7

vite-react-tailwind-starter

==== No longer actively maintained ==== Vite + React + Tailwindcss starter. React Router, and React Helmet preconfigured.
JavaScript
36
star
8

nextjs-tailwind-starter

A starter for Next.js and Tailwindcss, with Seo component.
JavaScript
32
star
9

rhf-input

React Hook Form Input Defaults
JavaScript
31
star
10

learn-auth-redirect-nextjs

Learning auth redirect on Next.js to prevent content flashing
JavaScript
31
star
11

dialog-manager

๐Ÿ’ฌ Dialog Manager using TypeScript, Zustand with Immer, and Tailwind CSS
TypeScript
25
star
12

recursive-component

TypeScript
19
star
13

lhokutang

๐Ÿ’ฐ App to track debt with your housemates
TypeScript
17
star
14

nextjs-with-auth-hoc

TypeScript
16
star
15

nextjs-fetch-usecase

Thorough explanation of how to choose between CSR, SSG, SSR, or ISR on Next.js
TypeScript
16
star
16

now-playing-spotify

JavaScript
13
star
17

learn-hover-radial-gradient

TypeScript
13
star
18

nextjs-csr-ssg-isr

Examples of 4 fetch methods in Next.js, explanation available in my blog https://theodorusclarence.com/blog/nextjs-fetch-method
TypeScript
13
star
19

react-patterns

TypeScript
10
star
20

git-emergency

๐Ÿ”ฅ save your work, then yourself
Shell
10
star
21

seasfor.us

Find beach clean-up events in your local coastal area
TypeScript
8
star
22

docs

๐Ÿ“ Personal documentation about my best practices on development
TypeScript
8
star
23

Tailwindcss-Injector

Firefox Addons for Injecting Tailwindcss Classes from CDN
JavaScript
4
star
24

wa-helper

A WhatsApp helper to avoid saving number to your contacts.
JavaScript
4
star
25

ta-multistepform

Sandbox for final project: refactoring PPDB Jatim from CI to Next.js
TypeScript
4
star
26

ios-custom-tab-swipe-gesture

Swift
4
star
27

love4heroes

An app to send thank you cards to frontline workers. The mission of this app is to let people share gratitude for frontline workers.
JavaScript
4
star
28

chat-app

JavaScript
3
star
29

rhf-multiple-select

example for dependent select option
TypeScript
3
star
30

react-loading-state-pattern

๐Ÿ”ฅ Hassle free asynchronous pattern using React Hot Toast, and SWR
TypeScript
3
star
31

grafkom-pertemuan-2

Triangle, Circle with WebGL
JavaScript
2
star
32

test-issue-autolink

TypeScript
2
star
33

task-manager-api

JavaScript
2
star
34

sxceosleague

StudentsxCEOs League website repository. Created with Next.js and Tailwindcss
JavaScript
2
star
35

dotfiles

Shell
2
star
36

learn-msw

Learn MSW with Next.js to mock server and browser request
TypeScript
2
star
37

learn-replicache-prisma

TypeScript
2
star
38

expansion-pack-demo

Demo & testing repository for ts-nextjs-tailwind-starter expansion pack
TypeScript
2
star
39

petrolida-2021

This is a website for Petrolida 2021 by SPE ITS SC. Made with Next.js, Tailwindcss, and GSAP.
JavaScript
2
star
40

learn-react-image-magnify

TypeScript
1
star
41

git-tips

1
star
42

learn-release-please

Test repository for release-please github actions
TypeScript
1
star
43

demo-responsive

HTML
1
star
44

fp-sisop-A08-2021

C
1
star
45

learn-nextts-auth

TypeScript react context example for user authentication. Also has full-page loader to prevent content flash
TypeScript
1
star
46

theodorusclarence

1
star
47

jarkom-shift2-gns

Shell
1
star
48

excalidraw-blog

Excalidraw files for my blog
1
star
49

learn-scrollspy

Example code of Scrollspy effect, useful for table of contents.
TypeScript
1
star
50

progate-calculator

Assignment to make calculator.
JavaScript
1
star
51

responsive-website-build

SCSS
1
star
52

learn-nextjs-cloudinary-loader

JavaScript
1
star
53

ios-360-skybox

Swift
1
star