Skip to content

Commit c53d3e4

Browse files
committed
🔥 Remove unused utils and constants
- `getDisplayName`, - `mapProps` - `defaultProps` - `withProps` - `useIsMounted` - `COLUMNS_PROP`
1 parent 234b0bd commit c53d3e4

File tree

3 files changed

+3
-38
lines changed

3 files changed

+3
-38
lines changed

‎src/flex-grid/constants.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
export const DEFAULT_GRID = 12
2-
export const COLUMNS_PROP = 'columns'

‎src/index.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,5 @@ export {
5858
} from './match-media'
5959

6060
export {
61-
createBase,
62-
mapProps,
63-
defaultProps,
64-
withProps
61+
createBase
6562
} from './utils'

‎src/utils.js

+2-33
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,11 @@
1-
import React, { useEffect, useState, useContext } from 'react'
2-
import { isFn, isStr } from '@exah/utils'
3-
import isPropValid from '@emotion/is-prop-valid'
1+
import { useContext } from 'react'
42
import { ThemeContext } from '@emotion/core'
3+
import isPropValid from '@emotion/is-prop-valid'
54
import { createBaseFactory } from 'react-styled-base'
65

76
export const createBase = createBaseFactory({ filter: isPropValid })
87
export const blacklistOf = (styles) => Object.keys(Object(styles.propTypes))
98

10-
export const getDisplayName = (comp, fallback = 'Component') =>
11-
(isStr(comp) ? comp : (comp.displayName || comp.name || fallback))
12-
13-
export const mapProps = (fn) => (Comp) => {
14-
const HOC = (props) => (
15-
<Comp {...fn(props)} />
16-
)
17-
18-
HOC.displayName = `mapProps(${getDisplayName(Comp)})`
19-
return HOC
20-
}
21-
22-
export const defaultProps = (data) => mapProps((props) => ({
23-
...isFn(data) ? data(props) : data,
24-
...props
25-
}))
26-
27-
export const withProps = (data) => mapProps((props) => ({
28-
...props,
29-
...isFn(data) ? data(props) : data
30-
}))
31-
32-
export function useIsMounted () {
33-
const [ isMounted, setIsMounted ] = useState(false)
34-
35-
useEffect(() => setIsMounted(true), [])
36-
37-
return isMounted
38-
}
39-
409
export function useTheme () {
4110
return useContext(ThemeContext)
4211
}

0 commit comments

Comments
 (0)