Skip to content

Commit e4d3dc2

Browse files
committed
fix: removed unecessary string match
1 parent 4c4f1c3 commit e4d3dc2

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

example/src/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import useBreakpoints from 'usebreakpoints'
44
const App = () => {
55
const breakpoints = [576, 768, 992, 1200]
66

7-
const stringBreakpoints = ['576px', '768px', '992px', '1200px']
7+
const stringBreakpoints = ['576px', '768lol', '992px', '1200px']
88

99
const [value, breakpoint] = useBreakpoints([1, 2, 3, 4], breakpoints)
1010

src/utils/isValidUnit.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ export default function isValidUnit(breakpoint: string) {
1919
const unit: string[] = breakpoint.match(/(\D+)/g) || ['']
2020

2121
if (!units.includes(unit[0])) {
22-
throw new Error(
23-
`"${breakpoint.match(/[^0-9]+/g)}" is not a valid CSS unit.`
24-
)
22+
throw new Error(`"${unit}" is not a valid CSS unit.`)
2523
}
2624

2725
return true

0 commit comments

Comments
 (0)