const form = useFormState({
email: '',
password: ''
})
// returns form.setEmail, form.email, form.setPassword, and form.password
<input value={form.email} onChange={form.setEmail} />
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 instance from './instance' | |
| import { toast } from '@app/components/Toast' | |
| import { AxiosRequestConfig, AxiosError } from 'axios'; | |
| interface IAxiosInterceptorValidationConfig extends AxiosRequestConfig { | |
| appValidationError?: string | boolean | |
| } | |
| interface IAxiosInterceptorValidationError extends AxiosError { | |
| config: IAxiosInterceptorValidationConfig |
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 subsetIncludes(array: any[], value: any): boolean { | |
| return Boolean( | |
| array.find(arrayValue => isSubset(arrayValue, 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
| import * as React from 'react' | |
| import { Route } from 'react-router-dom' | |
| import { RouteProps } from 'react-router' | |
| interface IRouterRouteProps extends RouteProps { | |
| component: any | |
| } | |
| class RouterRoute extends React.Component<IRouterRouteProps> { | |
| render() { |
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 * as React from 'react' | |
| import { Switch } from 'react-router-dom' | |
| interface IRouterSwitch { | |
| children: any | |
| } | |
| class RouterSwitch extends React.Component<IRouterSwitch, {}> { | |
| render() { | |
| const {children, ...rest} = this.props |
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 default function(organizationName: string) { | |
| const [f, l]: string[] = organizationName.split(' ') | |
| return [f.charAt(0).toUpperCase(), (l || '').charAt(0).toUpperCase()].join('') | |
| } |
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 * as React from 'react' | |
| import { Subscribe as UnstatedSubscribe } from 'unstated' | |
| import { AuthContainer } from '@app/containers' | |
| import { TAuthContainerUserData } from '@app/containers/AuthContainer' | |
| import { Redirect } from '@reach/router' | |
| import authOnly from './permission-auth-only' | |
| import guestOnly from './permission-auth-only' | |
| interface IPermissionFunction { | |
| guard: (user: TAuthContainerUserData) => boolean |
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 solution(A) { | |
| var natural = Array.from(new Array(10000)).map((_, i) => i + 1) | |
| return natural.sort((a, b) => a - b).find((n) => !A.includes(n)) | |
| } | |
| console.log(solution([1,2,5])) |
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 obj2arr(obj) { | |
| var arr = [] | |
| function flatten (subobj, isRoot) { | |
| var result = {} | |
| Object.keys(subobj).forEach(key => { | |
| if (typeof subobj[key] === 'object') { | |
| flatten(subobj[key], false) | |
| } else { | |
| result[key] = subobj[key] |