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
| #include <Adafruit_NeoPixel.h> | |
| #include <IRremote.h> | |
| #include <LiquidCrystal.h> | |
| #define LED_PIN 8 | |
| #define LED_COUNT 12 | |
| Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); |
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
Show hidden characters
| { | |
| "compilerOptions": { | |
| "lib": ["DOM", "DOM.Iterable", "ESNext"], | |
| "allowJs": true, | |
| "jsx": "react-jsx", | |
| "noEmit": true, | |
| "strict": true, | |
| "moduleResolution": "node", | |
| "resolveJsonModule": true, | |
| "isolatedModules": 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
| presets: ['module:babel-preset-expo'], | |
| plugins: [ | |
| ["module:react-native-dotenv", { | |
| "moduleName": "@env", | |
| "path": ".env", | |
| "blacklist": null, | |
| "whitelist": null, | |
| "safe": false, | |
| "allowUndefined": 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
| const valid = optionalRequiredSchema.isValidSync(state); |
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
| function handleChange(e) { | |
| setState({ optionalObject: { otherData: e.target.value } }); | |
| formik.setFieldValue("otherData", e.target.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
| <form onSubmit={formik.handleSubmit}> | |
| <h5>Handling dynamic validation with formik and yup</h5> | |
| <div | |
| className="text" | |
| style={{ backgroundColor: valid ? "green" : "red" }} | |
| > | |
| Valid Data: {"" + valid} | |
| </div> | |
| <input | |
| type="text" |
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 formik = useFormik({ | |
| initialValues: { | |
| otherData: state.optionalObject.otherData | |
| }, | |
| validationSchema: optionalRequiredSchema, | |
| onSubmit: values => { | |
| console.log(values); | |
| } | |
| }); |
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 [state, setState] = useState({ | |
| optionalObject: { | |
| otherData: "" | |
| } | |
| }); |
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 optionalRequiredSchema = yup.object().shape({ | |
| optionalObject: yup.lazy(value => { | |
| if (value !== undefined) { | |
| yup.mixed().notRequired(); | |
| } | |
| return yup.object().shape({ | |
| otherData: yup.string().required() | |
| }); | |
| }) | |
| }); |