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 mapItemSchema = new mongoose.Schema({ | |
| name: String, | |
| location: { | |
| // It's important to define type within type field, because | |
| // mongoose use "type" to identify field's object type. | |
| type: {type: String, default: 'Point'}, | |
| // Default value is needed. Mongoose pass an empty array to | |
| // array type by default, but it will fail MongoDB's pre-save | |
| // validation. | |
| coordinates: {type: [Number], default: [0, 0]} |
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 {forwardRef, useImperativeHandle, ForwardRefExoticComponent, RefAttributes, Ref} from "react"; | |
| export type Handle<T> = T extends ForwardRefExoticComponent<RefAttributes<infer T2>> ? T2 : never; | |
| export const Parent = (props: {})=> { | |
| let childHandle: Handle<typeof Child>; | |
| return ( | |
| <div onClick={()=>childHandle.SayHi()}> | |
| <Child name="Bob" ref={c=>childHandle = c}/> | |
| </div> |
OlderNewer