Skip to content

Commit cb7bccd

Browse files
CHEN HSUCHINGCHEN HSUCHING
authored andcommitted
add some doc
1 parent 145eb0f commit cb7bccd

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

doc/index.mdx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ name: Getting Start
33
route: /
44
---
55

6-
import { Playground } from 'docz';
6+
import { Playground, PropsTable } from 'docz';
77
import { State } from 'react-powerplug'
8-
import Input from '../bin/Input.js';
8+
import Input from '../src/components/Input.js';
99

1010
# React Autocorrect Input
1111

@@ -67,3 +67,6 @@ render(<Main />, document.getElementById('app'));
6767
</div>
6868
</Playground>
6969

70+
### Proptypes
71+
72+
<PropsTable of={Input} />

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "@reactmaker/react-autocorrect-input",
3-
"description": "react component for 8 bit style",
4-
"version": "1.0.3",
5-
"main": "bin/index.js",
3+
"description": "autocorrect input react component",
4+
"version": "1.0.0",
5+
"main": "bin/Input.js",
66
"repository": {
77
"type": "git",
88
"url": "https://github.com/reactmaker/react-autocorrect-input"
@@ -15,7 +15,6 @@
1515
"start": "webpack-dev-server --mode development --hot --config webpack.config.js",
1616
"build": "babel src/components/ --out-dir bin/",
1717
"deploy": "npm run docz:build && gh-pages -d .docz/dist",
18-
"build:docker": "npm run dist && docker build -t reactdocker .",
1918
"lint": "eslint ./src",
2019
"lint:fix": "eslint ./src --fix",
2120
"docz:dev": "docz dev",

src/components/Input.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ export default class ACInput extends React.Component {
6363
state = initState
6464

6565
onChange = (e) => {
66-
const { dataSource } = this.props;
66+
const { dataSource, onChange } = this.props;
6767
const { value, selectionStart } = e.target;
6868
// 1. get last keyword
6969
const lastWord = value.split(' ').pop().toLowerCase();
7070
if (!lastWord || selectionStart !== value.length) {
7171
this.setState(initState);
72-
this.props.onChange(value);
72+
onChange(value);
7373
return;
7474
}
7575
// 2. filter suggest
@@ -80,7 +80,7 @@ export default class ACInput extends React.Component {
8080
const selectedSuggest = suggest[0] || '';
8181
// 3. update suggest array
8282
this.setState({ suggest, selectedSuggest });
83-
this.props.onChange(value);
83+
onChange(value);
8484
}
8585

8686
onKeyDown(e) {
@@ -114,7 +114,7 @@ export default class ACInput extends React.Component {
114114
}
115115
}
116116

117-
onClickSuggest = (selectedSuggest) => () => {
117+
onClickSuggest = selectedSuggest => () => {
118118
this.onComplete(selectedSuggest);
119119
this.inputRef.current.focus();
120120
}

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Demo extends React.Component {
99
dataSource: ['apple', 'ask', 'applice', 'best', 'book', 'beep', 'cat', 'can', 'car'],
1010
}
1111

12-
onChange = (value) => this.setState({ value })
12+
onChange = value => this.setState({ value })
1313

1414
render() {
1515
const { value, dataSource } = this.state;

0 commit comments

Comments
 (0)