From ac3bfdfe5ffc4fc49b88fbad062e1d562987e728 Mon Sep 17 00:00:00 2001 From: fragosti Date: Mon, 15 Oct 2018 17:06:28 -0700 Subject: Put boundNoop in a util file --- packages/instant/src/components/amount_input.tsx | 3 ++- packages/instant/src/components/asset_amount_input.tsx | 3 ++- packages/instant/src/components/buy_button.tsx | 9 ++++----- packages/instant/src/util/util.ts | 5 +++++ 4 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 packages/instant/src/util/util.ts (limited to 'packages/instant') diff --git a/packages/instant/src/components/amount_input.tsx b/packages/instant/src/components/amount_input.tsx index 5b81a3d68..7644f5f67 100644 --- a/packages/instant/src/components/amount_input.tsx +++ b/packages/instant/src/components/amount_input.tsx @@ -3,6 +3,7 @@ import * as _ from 'lodash'; import * as React from 'react'; import { ColorOption } from '../style/theme'; +import { util } from '../util/util'; import { Container, Input } from './ui'; @@ -15,7 +16,7 @@ export interface AmountInputProps { export class AmountInput extends React.Component { public static defaultProps = { - onChange: _.noop.bind(_), + onChange: util.boundNoop, }; public render(): React.ReactNode { const { fontColor, fontSize, value } = this.props; diff --git a/packages/instant/src/components/asset_amount_input.tsx b/packages/instant/src/components/asset_amount_input.tsx index 72bcfb8fb..7c6b03ee9 100644 --- a/packages/instant/src/components/asset_amount_input.tsx +++ b/packages/instant/src/components/asset_amount_input.tsx @@ -5,6 +5,7 @@ import * as React from 'react'; import { assetMetaData } from '../data/asset_meta_data'; import { ColorOption } from '../style/theme'; +import { util } from '../util/util'; import { AmountInput, AmountInputProps } from './amount_input'; import { Container, Text } from './ui'; @@ -16,7 +17,7 @@ export interface AssetAmountInputProps extends AmountInputProps { export class AssetAmountInput extends React.Component { public static defaultProps = { - onChange: _.noop.bind(_), + onChange: util.boundNoop, }; public render(): React.ReactNode { const { assetData, onChange, ...rest } = this.props; diff --git a/packages/instant/src/components/buy_button.tsx b/packages/instant/src/components/buy_button.tsx index e9466619e..0706817c9 100644 --- a/packages/instant/src/components/buy_button.tsx +++ b/packages/instant/src/components/buy_button.tsx @@ -4,6 +4,7 @@ import * as React from 'react'; import { ColorOption } from '../style/theme'; import { assetBuyer } from '../util/asset_buyer'; +import { util } from '../util/util'; import { web3Wrapper } from '../util/web3_wrapper'; import { Button, Container, Text } from './ui'; @@ -16,13 +17,11 @@ export interface BuyButtonProps { text: string; } -const boundNoop = _.noop.bind(_); - export class BuyButton extends React.Component { public static defaultProps = { - onClick: boundNoop, - onBuySuccess: boundNoop, - onBuyFailure: boundNoop, + onClick: util.boundNoop, + onBuySuccess: util.boundNoop, + onBuyFailure: util.boundNoop, }; public render(): React.ReactNode { const shouldDisableButton = _.isUndefined(this.props.buyQuote); diff --git a/packages/instant/src/util/util.ts b/packages/instant/src/util/util.ts new file mode 100644 index 000000000..232a86850 --- /dev/null +++ b/packages/instant/src/util/util.ts @@ -0,0 +1,5 @@ +import * as _ from 'lodash'; + +export const util = { + boundNoop: _.noop.bind(_), +}; -- cgit v1.2.3