-
-
Save RileySeaburg/b33dd230d9d98b716ed66effd7a53710 to your computer and use it in GitHub Desktop.
React Forms Input with Shopify Polaris & Typescript
This file contains 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, { ReactElement, useState, useCallback } from 'react' | |
import { TextField, FormLayout, Form } from '@shopify/polaris'; | |
export default function ButtonForm(): ReactElement { | |
const [buttonText, setbuttonText] = useState('Button text'); | |
const handleSubmit = (e: React.SyntheticEvent<HTMLFormElement>) => { | |
e.preventDefault(); | |
console.log(buttonText); | |
}; | |
const handleChange = useCallback((newButtonText) => setbuttonText(newButtonText), []); | |
console.log(buttonText) | |
return ( | |
<Form onSubmit={handleSubmit}> | |
<FormLayout > | |
<TextField | |
id="ButtonText" | |
label="Button Text" | |
onChange={handleChange} | |
value={buttonText} | |
/> | |
</FormLayout> | |
</Form> | |
) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment