Skip to content

Commit

Permalink
refactor: use ?? + remove unnecessary typeof
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecadavid committed Jun 13, 2023
1 parent 3ba2c22 commit b5febb9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions packages/react/counter/src/Counter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ export function Counter(props: CounterProps) {
uniqueName: query?.metric,
counterInput: {
timeRange: {
relative: query?.timeRange?.relative || null,
n: query?.timeRange?.n || null,
start: query?.timeRange?.start || null,
stop: query?.timeRange?.stop || null
relative: query?.timeRange?.relative ?? null,
n: query?.timeRange?.n ?? null,
start: query?.timeRange?.start ?? null,
stop: query?.timeRange?.stop ?? null
},
filters,
propeller: query?.propeller
Expand Down Expand Up @@ -141,7 +141,7 @@ export function Counter(props: CounterProps) {
if (!isStatic) {
const fetchedValue = await fetchData()

if (typeof fetchedValue === 'undefined') {
if (fetchedValue === undefined) {
setHasError(true)
console.error(`QueryError: Your metric ${query?.metric} returned undefined.`)
return
Expand Down
2 changes: 1 addition & 1 deletion packages/react/counter/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const getValueWithPrefixAndSufix = (params: {
}) => {
const { prefix, value, sufix, localize } = params

if (typeof value === 'undefined') return
if (value === undefined) return

return (prefix ? prefix : '') + getValue({ value, localize }) + (sufix ? sufix : '')
}
8 changes: 4 additions & 4 deletions packages/react/leaderboard/src/Leaderboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ export function Leaderboard(props: LeaderboardProps) {
rowLimit: query?.rowLimit,
dimensions,
timeRange: {
relative: query?.timeRange?.relative || null,
n: query?.timeRange?.n || null,
start: query?.timeRange?.start || null,
stop: query?.timeRange?.stop || null
relative: query?.timeRange?.relative ?? null,
n: query?.timeRange?.n ?? null,
start: query?.timeRange?.start ?? null,
stop: query?.timeRange?.stop ?? null
}
}
},
Expand Down
8 changes: 4 additions & 4 deletions packages/react/time-series/src/TimeSeries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,10 @@ export function TimeSeries(props: TimeSeriesProps) {
uniqueName: query?.metric,
timeSeriesInput: {
timeRange: {
relative: query?.timeRange?.relative || null,
n: query?.timeRange?.n || null,
start: query?.timeRange?.start || null,
stop: query?.timeRange?.stop || null
relative: query?.timeRange?.relative ?? null,
n: query?.timeRange?.n ?? null,
start: query?.timeRange?.start ?? null,
stop: query?.timeRange?.stop ?? null
},
granularity,
filters: filters,
Expand Down

0 comments on commit b5febb9

Please sign in to comment.