// flutter
setState(() {
name = newValue
})// react
this.setState({| const capitalizeIt = (text: string) => text.replace(/[a-z]/, (letter) => letter.toUpperCase()); |
| /** | |
| * In this short assessment, the following code tries to implement the React Suspense API, | |
| * but does so incorrectly. There are 3 core issues with how these components utilize Suspense and concurrent mode -- can you find them? | |
| * | |
| * In your submission, be sure to: | |
| * 1) Clearly identify what the 3 core issues are, and how they violate the principles of React Suspense; | |
| * 2) Write and submit the code to fix the core issues you have identified in a gist of your own | |
| * | |
| * If you aren't familiar with Suspense, the docs are a good starting place: | |
| * |
| // de: | |
| const MyInput = ({ onChange, value }) => ( | |
| <Container> | |
| <Label htmlFor="campoId"> | |
| Campo X | |
| <Input id="campoId" onChange={onChange} value={value} /> | |
| </Label> | |
| </Container> | |
| ) | |
| // para: |
| { | |
| 'consistent-return': 'off', | |
| 'no-shadow': 'off', | |
| 'global-require': 'off', | |
| 'react/require-default-props': 'off', | |
| 'react/react-in-jsx-scope': 'off', | |
| 'react/jsx-filename-extension': 'off', | |
| 'react/prop-types': 'off', | |
| 'react/jsx-props-no-spreading': 'off', |
| class Container extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return MyButton(title: 'Titulo do button'); | |
| } | |
| } | |
| class MyButton extends StatelessWidget { | |
| String title; |
// flutter
setState(() {
name = newValue
})// react
this.setState({| Number(5).toLocaleString('pt-BR', {style: 'currency',currency: 'BRL'}) |
| // {...} | |
| <div> | |
| <form> | |
| <input placeholder="Name" {...formik.getFieldProps("name")} /> | |
| <br /> | |
| <input placeholder="Email" {...formik.getFieldProps("email")} /> | |
| <br /> | |
| <input placeholder="Password" {...formik.getFieldProps("password")} /> | |
| <br /> | |
| <input |
| import React from "react"; | |
| import { useFormik } from "formik"; | |
| const initialValues = { | |
| name: "", | |
| email: "", | |
| address: { | |
| street: "", | |
| number: "", | |
| city: "" |
| const [primaryAddress, setPrimaryAddress] = useState('') | |
| const [secondaryAddress, setSecondaryAddress] = useState('') | |
| useEffect(() => { | |
| setPrimaryAddress(props.priAddress) | |
| }, [props.priAddress]) | |
| useEffect(() => { | |
| setSecondaryAddress(props.secAddress) | |
| }, [props.secAddress]) |