Skip to content

Commit c077797

Browse files
author
Oliver ALR
committed
Code Minified
1 parent 7ad3296 commit c077797

File tree

5 files changed

+101
-49
lines changed

5 files changed

+101
-49
lines changed

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"trailingComma": "es5",
3+
"tabWidth": 4,
4+
"semi": false,
5+
"singleQuote": true
6+
}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<div align="center">
1111
<!-- Badges -->
1212

13-
![Release](https://img.shields.io/badge/release-v1.0.0-success)&nbsp;![Dependencies](https://img.shields.io/badge/dependencies-up%20to%20date-success)&nbsp;![Version](https://img.shields.io/github/v/release/facebook/react?logo=react)&nbsp;![License](https://img.shields.io/npm/l/react?color=blue)
13+
![Release](https://img.shields.io/badge/release-v1.0.3-success)&nbsp;![Dependencies](https://img.shields.io/badge/dependencies-up%20to%20date-success)&nbsp;![Version](https://img.shields.io/github/v/release/facebook/react?logo=react)&nbsp;![License](https://img.shields.io/npm/l/react?color=blue)
1414

1515
</div>
1616

@@ -49,8 +49,8 @@ npm install react-hider
4949
import Hider from 'react-hider'
5050
```
5151

52-
Wrap first the component to show and second the component to hide
53-
inside Hider(library provided) or use pure raw jsx and provide a <strong>boolean(true/false)</strong> state:
52+
Wrap first the component to show and second the component to hide
53+
inside Hider(library provided) or use pure raw jsx and provide a <strong>boolean(true/false)</strong> state:
5454

5555
```jsx
5656
<Hider state={boolean}>

package-lock.json

Lines changed: 46 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,45 @@
11
{
2-
"name": "react-hider",
3-
"version": "1.0.0",
4-
"description": "",
5-
"main": "dist/index.js",
6-
"scripts": {
7-
"build": "rollup -c",
8-
"start": "rollup -c -w"
9-
},
10-
"keywords": [],
11-
"author": "",
12-
"license": "ISC",
13-
"peerDependencies": {
14-
"react": "^16.8.0",
15-
"react-dom": "^16.8.0"
16-
},
17-
"files": [
18-
"dist"
19-
],
20-
"devDependencies": {
21-
"@babel/core": "^7.10.2",
22-
"@babel/preset-react": "^7.10.1",
23-
"babel-core": "^6.26.3",
24-
"babel-preset-react": "^6.24.1",
25-
"babel-runtime": "^6.26.0",
26-
"react": "^16.13.1",
27-
"react-dom": "^16.13.1",
28-
"rollup": "^2.13.1",
29-
"rollup-plugin-babel": "^4.4.0",
30-
"rollup-plugin-commonjs": "^10.1.0"
31-
}
2+
"name": "react-hider",
3+
"version": "1.0.3",
4+
"description": "Conditional Rendering Made Easy",
5+
"main": "dist/index.js",
6+
"scripts": {
7+
"build": "rollup -c",
8+
"start": "rollup -c -w"
9+
},
10+
"keywords": [
11+
"Conditional Rendering",
12+
"react hider",
13+
"hider",
14+
"react",
15+
"rendering",
16+
"logical rendering",
17+
"hide elements",
18+
"hide",
19+
"conditional rendering"
20+
],
21+
"author": "",
22+
"license": "ISC",
23+
"peerDependencies": {
24+
"react": "^16.8.0",
25+
"react-dom": "^16.8.0"
26+
},
27+
"files": [
28+
"dist"
29+
],
30+
"devDependencies": {
31+
"@babel/core": "^7.10.2",
32+
"@babel/preset-react": "^7.10.1",
33+
"babel-core": "^6.26.3",
34+
"babel-preset-react": "^6.24.1",
35+
"babel-runtime": "^6.26.0",
36+
"react": "^16.13.1",
37+
"react-dom": "^16.13.1",
38+
"rollup": "^2.13.1",
39+
"rollup-plugin-babel": "^4.4.0",
40+
"rollup-plugin-commonjs": "^10.1.0"
41+
},
42+
"dependencies": {
43+
"prettier": "^2.0.5"
44+
}
3245
}

src/index.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,15 @@ const Hider = ({ state, children }) => {
1212
const count = React.Children.count(children)
1313
// Show/Hide a single element based on boolean status
1414
if (count === 1) {
15-
return (
16-
<>
17-
{state && <>{children}</>}
18-
</>
19-
)
15+
return <>{state && <>{children}</>}</>
2016
}
2117
// Show/Hide elements based on component's boolean status
2218
else if (count === 2) {
23-
return (
24-
<>
25-
{state ? (
26-
<>{children[0]}</>
27-
) : (
28-
<>{children[1]}</>
29-
)}
30-
</>
31-
)
19+
return <>{state ? <>{children[0]}</> : <>{children[1]}</>}</>
3220
}
3321
// Nothing is returned if there are n = 0 OR n > 2 children nodes
3422
else {
35-
return <></>
23+
return <>{children}</>
3624
}
3725
}
3826
//Export default module "d(^o^)p"

0 commit comments

Comments
 (0)