This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const formData = { | |
success: 'Hooray! Your form submitted.', | |
fields: [ | |
{ | |
name: 'name', | |
type: 'text', | |
placeholder: 'Dana Scully', | |
value: '' | |
}, | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"success":"Hooray! your form was submitted.", | |
"fields":[ | |
{ | |
"name":"name", | |
"type":"text", | |
"placeholder":"Dana Scully", | |
"required":true | |
}, | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect } from 'react' | |
const FormHook = () => { | |
// return something here... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Form = () => { | |
return ( | |
<div className="HookForm" css={CSS}> | |
</div> | |
) | |
} | |
const Form = css` | |
height: 100%; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect } from 'react' | |
// form will be the JSON file | |
const FormHook = (form) => { | |
const [formData, setFormData] = useState(form) | |
// | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"success":"Hooray! your form was submitted.", | |
"fields":[ | |
{ | |
"name":"name", | |
"type":"text", | |
"placeholder":"Dana Scully", | |
"required":true, | |
"value": "" | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Upload = () => { | |
const [files, setFiles] = useState([]) | |
const inputRef = useRef() | |
const handleClick = () => { | |
inputRef.current.click() | |
} | |
const handleFiles = (fileList, mode = 'w') => { | |
if (mode === 'a') { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Upload = () => { | |
const [files, setFiles] = useState([]) | |
const inputRef = useRef() | |
const handleClick = () => { | |
inputRef.current.click() | |
} | |
const handleFiles = (fileList, mode = 'w') => { | |
if (mode === 'a') { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |