Skip to content

Instantly share code, notes, and snippets.

@DZuz14
DZuz14 / index.js
Created July 17, 2021 15:28
config.js
const formData = {
success: 'Hooray! Your form submitted.',
fields: [
{
name: 'name',
type: 'text',
placeholder: 'Dana Scully',
value: ''
},
{
@DZuz14
DZuz14 / form.json
Last active July 16, 2021 19:50
formdata
{
"success":"Hooray! your form was submitted.",
"fields":[
{
"name":"name",
"type":"text",
"placeholder":"Dana Scully",
"required":true
},
{
@DZuz14
DZuz14 / index.js
Created July 15, 2021 17:46
FORMHOOK2
import React, { useState, useEffect } from 'react'
const FormHook = () => {
// return something here...
}
@DZuz14
DZuz14 / index.jsx
Last active July 16, 2021 19:35
FORMHOOK1
const Form = () => {
return (
<div className="HookForm" css={CSS}>
</div>
)
}
const Form = css`
height: 100%;
@DZuz14
DZuz14 / index.js
Created July 15, 2021 16:53
hook2
import React, { useState, useEffect } from 'react'
// form will be the JSON file
const FormHook = (form) => {
const [formData, setFormData] = useState(form)
//
}
@DZuz14
DZuz14 / hook.js
Last active July 16, 2021 19:53
hook1
import React from 'react'
import formData from './form-data.json
const FormHook = () => {
return <div>
{
formData.fields.map(field =>
<input
type={field.type}
name={field.name}
@DZuz14
DZuz14 / config.json
Last active July 16, 2021 19:59
autoform 1
{
"success":"Hooray! your form was submitted.",
"fields":[
{
"name":"name",
"type":"text",
"placeholder":"Dana Scully",
"required":true,
"value": ""
},
@DZuz14
DZuz14 / index.jsx
Last active July 13, 2021 15:42
Upload Last
const Upload = () => {
const [files, setFiles] = useState([])
const inputRef = useRef()
const handleClick = () => {
inputRef.current.click()
}
const handleFiles = (fileList, mode = 'w') => {
if (mode === 'a') {
@DZuz14
DZuz14 / index.jsx
Created July 8, 2021 23:41
Upload 8
const Upload = () => {
const [files, setFiles] = useState([])
const inputRef = useRef()
const handleClick = () => {
inputRef.current.click()
}
const handleFiles = (fileList, mode = 'w') => {
if (mode === 'a') {
@DZuz14
DZuz14 / index.jsx
Last active July 9, 2021 15:11
Upload 7
const Upload = () => {
const [files, setFiles] = useState(null)
const inputRef = useRef()
const handleClick = () => {
inputRef.current.click()
}
const removeFile = (name) => {
const newFiles = files.filter((file) => file.name !== name)