Skip to content

Commit 9b66eb4

Browse files
committed
Add default usage to README
1 parent 71484b3 commit 9b66eb4

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ typed(MyComponent, {
3232
},
3333
fruitCount: {
3434
type: typed.number,
35+
default: 0,
3536
description: 'The number of fruit eaten'
3637
},
3738
fruit: {
3839
type: typed.oneOf(['bananas', 'mangoes']),
40+
default: 'bananas',
3941
description: 'The number of fruit eaten'
4042
},
4143
})
@@ -54,15 +56,31 @@ console.log(MyComponent.types)
5456
},
5557
fruitCount: {
5658
type: 'number',
59+
default: 0,
5760
description: 'The number of fruit eaten'
5861
},
5962
fruit: {
6063
type: { name: 'oneOf', params: ['bananas', 'mangoes'] },
64+
default: 'bananas',
6165
description: 'The number of fruit eaten'
6266
},
6367
}
6468
*/
6569
```
70+
and your installed version of [prop-types][1] is applied
71+
72+
```js
73+
MyComponent.propTypes = {
74+
name: PropTypes.string.isRequired,
75+
fruitCount: PropTypes.number,
76+
fruit: PropTypes.oneOf(['bananas', 'mangoes'])
77+
}
78+
79+
MyComponent.defaultProps = {
80+
fruitCount: 0,
81+
fruit: 'bananas'
82+
}
83+
```
6684

6785
### WHY?
6886
PropTypes is great for regular use but when building components that need to be documented, it

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "typable-react",
3-
"version": "0.0.3",
4-
"description": "React.js prop-types wrapper for easy extraction",
3+
"version": "0.0.4",
4+
"description": "React.js prop-types wrapper for easy extraction to documentation",
55
"main": "typable.js",
66
"scripts": {
77
"test": "jest"
@@ -13,7 +13,10 @@
1313
"keywords": [
1414
"static",
1515
"typed",
16-
"prop-types"
16+
"prop-types",
17+
"react",
18+
"extract",
19+
"documentation"
1720
],
1821
"author": "Joseph Rex",
1922
"license": "MIT",

publish.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Usage:
22
# publish 1.2 "my publish message"
33

4-
npm run build
4+
# npm run build
55
sed -i "" "3s/: .*/: \"$1\",/" package.json
66
git add .
77
git commit -m "$2"
88
git tag -a "v$1" -m "$2"
99
git push origin --tags
1010
git push origin main
11-
npm publish
11+
# npm publish

0 commit comments

Comments
 (0)