From 6cf61932cc9823d3e347768a847bca0830998256 Mon Sep 17 00:00:00 2001 From: Umair Ahmed Date: Tue, 29 May 2018 10:14:14 +0100 Subject: [PATCH] updating const to let --- util.js | 70 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/util.js b/util.js index d2338dd..ad9de51 100644 --- a/util.js +++ b/util.js @@ -1,35 +1,43 @@ -import { StyleSheet } from 'react-native' +import { StyleSheet } from 'react-native'; -export const isStyleRow = (style) => { - const flatStyle = StyleSheet.flatten(style || {}) - return flatStyle.flexDirection !== 'column' -} +export const isStyleRow = style => { + const flatStyle = StyleSheet.flatten(style || {}); + return flatStyle.flexDirection !== 'column'; +}; -const getDashStyleId = ({ dashGap, dashLength, dashThickness, dashColor }, isRow) => - `${dashGap}-${dashLength}-${dashThickness}-${dashColor}-${isRow ? 'row' : 'column'}` +const getDashStyleId = ( + { dashGap, dashLength, dashThickness, dashColor }, + isRow +) => + `${dashGap}-${dashLength}-${dashThickness}-${dashColor}-${ + isRow ? 'row' : 'column' + }`; -const createDashStyleSheet = ({ dashGap, dashLength, dashThickness, dashColor }, isRow) => { - const idStyle = new StyleSheet.create({ - style: { - width: isRow ? dashLength : dashThickness, - height: isRow ? dashThickness : dashLength, - marginRight: isRow ? dashGap : 0, - marginBottom: isRow ? 0 : dashGap, - backgroundColor: dashColor, - }, - }) - return idStyle.style -} +const createDashStyleSheet = ( + { dashGap, dashLength, dashThickness, dashColor }, + isRow +) => { + const idStyle = new StyleSheet.create({ + style: { + width: isRow ? dashLength : dashThickness, + height: isRow ? dashThickness : dashLength, + marginRight: isRow ? dashGap : 0, + marginBottom: isRow ? 0 : dashGap, + backgroundColor: dashColor, + }, + }); + return idStyle.style; +}; -const stylesStore = {} -export const getDashStyle = (props) => { - const isRow = isStyleRow(props.style) - const id = getDashStyleId(props, isRow) - if (!stylesStore[ id ]) { - stylesStore = { - ...stylesStore, - [ id ]: createDashStyleSheet(props, isRow), - } - } - return stylesStore[ id ] -} +let stylesStore = {}; +export const getDashStyle = props => { + const isRow = isStyleRow(props.style); + const id = getDashStyleId(props, isRow); + if (!stylesStore[id]) { + stylesStore = { + ...stylesStore, + [id]: createDashStyleSheet(props, isRow), + }; + } + return stylesStore[id]; +};