Optional - Set format on save and any global prettier options
npm i -D eslint prettier eslint-plugin-prettier eslint-config-prettier eslint-plugin-node eslint-config-node
| const FakeComponent = () => { | |
| return ( | |
| <AnimatedRoutes exitBeforeEnter initial={false}> | |
| <RouteTransition exact path="/some-route"> | |
| <NewUsers /> | |
| </RouteTransition> | |
| <RouteTransition exact path="/yo" > | |
| <Users /> | |
| </RouteTransition> | |
| </AnimatedRoutes> |
| #import <UIKit/UIKit.h> | |
| #import <UMReactNativeAdapter/UMModuleRegistryAdapter.h> | |
| #import <React/RCTBridgeDelegate.h> | |
| @interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate> | |
| @property (nonatomic, strong) UMModuleRegistryAdapter *moduleRegistryAdapter; | |
| @property (nonatomic, strong) UIWindow *window; | |
| @end |
| // web/webpack.config.js | |
| const path = require('path'); | |
| const webpack = require('webpack'); | |
| const appDirectory = path.resolve(__dirname, '../'); | |
| // This is needed for webpack to compile JavaScript. | |
| // Many OSS React Native packages are not compiled to ES5 before being | |
| // published. If you depend on uncompiled packages they may cause webpack build |
| export function debounce<F extends Function>(func:F, wait:number):F { | |
| let timeoutID:number; | |
| if (!Number.isInteger(wait)) { | |
| console.warn("Called debounce without a valid number") | |
| wait = 300; | |
| } | |
| // conversion through any necessary as it wont satisfy criteria otherwise | |
| return <any>function(this:any, ...args: any[]) { |
| const log = new Proxy({}, { | |
| get: (_, colour) => function() { | |
| console.log(`%c ${[].slice.call(arguments).join(' ')}`, `color: ${colour}`) | |
| } | |
| }) | |
| // example | |
| log.tomato('I am tomato') | |
| log.chocolate('I am chocolate') | |
| log.cornflowerblue('I am cornflowerblue') |
| /** | |
| * Copyright 2017 Zohaib Sibte Hassan | |
| * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
| * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWAR |
This document details some tips and tricks for creating redux containers. Specifically, this document is looking at the mapDispatchToProps argument of the connect function from [react-redux][react-redux]. There are many ways to write the same thing in redux. This gist covers the various forms that mapDispatchToProps can take.
| // Originally inspired by David Walsh (https://davidwalsh.name/javascript-debounce-function) | |
| // Returns a function, that, as long as it continues to be invoked, will not | |
| // be triggered. The function will be called after it stops being called for | |
| // `wait` milliseconds. | |
| const debounce = (func, wait) => { | |
| let timeout; | |
| return function executedFunction(...args) { | |
| const later = () => { |
| // Originally inspired by David Walsh (https://davidwalsh.name/javascript-debounce-function) | |
| // Returns a function, that, as long as it continues to be invoked, will not | |
| // be triggered. The function will be called after it stops being called for | |
| // `wait` milliseconds. | |
| const debounce = (func, wait) => { | |
| let timeout; | |
| // This is the function that is returned and will be executed many times | |
| // We spread (...args) to capture any number of parameters we want to pass |