This repository was archived by the owner on Jun 2, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 7 files changed +30
-33
lines changed Expand file tree Collapse file tree 7 files changed +30
-33
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"lib/index.esm.js" : {
3
- "bundled" : 5035 ,
4
- "minified" : 2602 ,
5
- "gzipped" : 945 ,
3
+ "bundled" : 4740 ,
4
+ "minified" : 2528 ,
5
+ "gzipped" : 923 ,
6
6
"treeshaked" : {
7
7
"rollup" : {
8
- "code" : 1185 ,
8
+ "code" : 1146 ,
9
9
"import_statements" : 195
10
10
},
11
11
"webpack" : {
12
- "code" : 3075
12
+ "code" : 3036
13
13
}
14
14
}
15
15
}
Original file line number Diff line number Diff line change @@ -18,16 +18,15 @@ interface IListProps {
18
18
/**
19
19
* Renders content from specified callback function from either `render` or `children` on each element of `items`.
20
20
*/
21
- const List = ( props : IListProps ) : TOutput => {
22
- const { items, children, render } = props ;
23
- const renderProp = getRenderProp ( children , render ) ;
21
+ function List ( props : IListProps ) : TOutput {
22
+ const renderProp = getRenderProp ( props . children , props . render ) ;
24
23
25
24
if ( ! ! renderProp && isFunction < TMap > ( renderProp ) ) {
26
- return < React . Fragment > { items . map ( renderProp ) } </ React . Fragment > ;
25
+ return < React . Fragment > { props . items . map ( renderProp ) } </ React . Fragment > ;
27
26
}
28
27
29
28
return null ;
30
- } ;
29
+ }
31
30
32
31
List . propTypes = {
33
32
children : PropTypes . func ,
Original file line number Diff line number Diff line change @@ -11,10 +11,9 @@ interface IShowProps extends IRenderProps {
11
11
/**
12
12
* Renders content if `when` equals true.
13
13
*/
14
- const Show = ( props : IShowProps ) : TOutput => {
15
- const { when, children, render } = props ;
16
- return when ? getChildrenOrRender ( children , render ) : null ;
17
- } ;
14
+ function Show ( props : IShowProps ) : TOutput {
15
+ return props . when ? getChildrenOrRender ( props . children , props . render ) : null ;
16
+ }
18
17
19
18
Show . propTypes = {
20
19
when : PropTypes . bool . isRequired ,
Original file line number Diff line number Diff line change @@ -18,12 +18,14 @@ interface IShowIfElse {
18
18
/**
19
19
* Renders content from if when condition equals true, else renders content from else.
20
20
*/
21
- const ShowIfElse = ( props : IShowIfElse ) : TOutput => (
22
- < Switch value = { true } >
23
- < Switch . Case value = { props . condition } render = { props . if } />
24
- < Switch . Default render = { props . else } />
25
- </ Switch >
26
- ) ;
21
+ function ShowIfElse ( props : IShowIfElse ) : TOutput {
22
+ return (
23
+ < Switch value = { true } >
24
+ < Switch . Case value = { props . condition } render = { props . if } />
25
+ < Switch . Default render = { props . else } />
26
+ </ Switch >
27
+ ) ;
28
+ }
27
29
28
30
ShowIfElse . propTypes = {
29
31
condition : PropTypes . bool . isRequired ,
Original file line number Diff line number Diff line change @@ -18,13 +18,12 @@ const getSwitchCaseValue = (element: any) => element.props.value;
18
18
/**
19
19
* Renders content from first `Switch.Case` that matches `value`, else `Switch.Default` if it exists.
20
20
*/
21
- const Switch = ( props : ISwitchProps ) : TOutput => {
22
- const { children, value } = props ;
23
- const switchValue = value ;
21
+ function Switch ( props : ISwitchProps ) : TOutput {
22
+ const switchValue = props . value ;
24
23
let match = false ;
25
24
let child : any ;
26
25
27
- React . Children . forEach ( children , ( element : any ) => {
26
+ React . Children . forEach ( props . children , ( element : any ) => {
28
27
if ( match === false && React . isValidElement ( element ) ) {
29
28
const caseValue = getSwitchCaseValue ( element ) ;
30
29
child = element ;
@@ -39,7 +38,7 @@ const Switch = (props: ISwitchProps): TOutput => {
39
38
40
39
// Return case if its a match.
41
40
return match ? React . cloneElement ( child ) : null ;
42
- } ;
41
+ }
43
42
44
43
Switch . Case = SwitchCase ;
45
44
Original file line number Diff line number Diff line change @@ -11,10 +11,9 @@ export interface ISwitchCaseProps extends IRenderProps {
11
11
/**
12
12
* Helper component that is accessed from `Switch` component.
13
13
*/
14
- const SwitchCase = ( props : ISwitchCaseProps ) : TOutput => {
15
- const { children, render } = props ;
16
- return getChildrenOrRender ( children , render ) ;
17
- } ;
14
+ function SwitchCase ( props : ISwitchCaseProps ) : TOutput {
15
+ return getChildrenOrRender ( props . children , props . render ) ;
16
+ }
18
17
19
18
SwitchCase . propTypes = {
20
19
value : PropTypes . any . isRequired ,
Original file line number Diff line number Diff line change @@ -4,10 +4,9 @@ import { getChildrenOrRender } from '../../utils/';
4
4
/**
5
5
* Helper component that is accessed from `Switch` component.
6
6
*/
7
- const SwitchDefault = ( props : IRenderProps ) : TOutput => {
8
- const { children, render } = props ;
9
- return getChildrenOrRender ( children , render ) ;
10
- } ;
7
+ function SwitchDefault ( props : IRenderProps ) : TOutput {
8
+ return getChildrenOrRender ( props . children , props . render ) ;
9
+ }
11
10
12
11
SwitchDefault . propTypes = renderPropsPropTypes ;
13
12
You can’t perform that action at this time.
0 commit comments