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 A() { | |
| const [state] = useState([]) | |
| return ( | |
| <div>{state}</div> | |
| ) | |
| } | |
| A() | |
| <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 Container = () => { | |
| const [isOutlined, setIsOutlined] = useState(false); | |
| const [isDisabled, setIsDisabled] = useState(false); | |
| return ( | |
| <> | |
| <Button | |
| type="info" | |
| text={isDisabled ? "Disabled: true" : "Disabled: false"} | |
| style={{ margin: 10 }} |
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
| React.cloneElement( | |
| element, | |
| [props], | |
| [...children] | |
| ) | |
| <element.type {...element.props} {...props}>{children}</element.type> |
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 Editable = ({ children }) => { | |
| const [isEditing, setIsEditing] = useState(false); | |
| return ( | |
| <FieldContainer> | |
| {React.Children.map(children, (child) => | |
| React.cloneElement(child, { isEditing }) | |
| )} | |
| <Button |
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 Selectable = ({children, onPress, mode = "singleChoice"}) => { | |
| const initial = React.Children.map( | |
| children ?? [], | |
| (child) => !!child.props.checked | |
| ); | |
| const [checkedArray, setCheckedArray] = useState(initial); | |
| const [checkedIndex, setCheckedIndex] = useState( | |
| initial.findIndex((value) => value === 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 SingleChoice = () => { | |
| const [value, setValue] = useState("2"); | |
| return ( | |
| <Container> | |
| <Selectable mode="singleChoice" onPress={setValue}> | |
| <Checkbox type="primary" checked={false} /> | |
| <Checkbox type="secondary" checked={false} /> | |
| <Checkbox type="success" checked={true} /> | |
| <Checkbox type="warning" checked={false} /> |
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 Submittable = ({ children }) => { | |
| const refs = Array(children.length).fill(null).map(useRef); | |
| return React.Children.map(children, (child, i) => { | |
| const isLast = i === children.length - 1; | |
| return React.cloneElement(child, { | |
| inputRef: refs[i], | |
| onSubmitEditing: !isLast ? () => refs[i + 1].current.focus() : undefined | |
| }); |
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 { generatorHandler } from '@prisma/generator-helper'; | |
| generatorHandler({ | |
| onManifest() { | |
| return { | |
| defaultOutput: './schema', | |
| prettyName: 'GraphQL-Schema-Generator', | |
| }; | |
| }, | |
| async onGenerate(options) { |
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
| export declare type GeneratorOptions = { | |
| generator: GeneratorConfig; | |
| otherGenerators: GeneratorConfig[]; | |
| schemaPath: string; | |
| dmmf: DMMF.Document; | |
| datasources: DataSource[]; | |
| datamodel: string; | |
| version: string; | |
| binaryPaths?: BinaryPaths; | |
| }; |
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 convertedType = rules.reduce( | |
| (type, {matcher, transformer}: Rule): string => { | |
| if (!matcher(field, model)) { | |
| return type; | |
| } | |
| return transformer(field, type); | |
| }, | |
| initialType, | |
| ); |
OlderNewer