Skip to content

Commit 5518868

Browse files
committed
fix: onChange function type fix
1 parent 188859e commit 5518868

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ import CounterInput from "react-native-counter-input";
5858

5959
| Property | Type | Default | Description |
6060
| ----------------------------- | :-------: | :-------: | ----------------------------------------------------------------------------------------- |
61-
| onChange | function | undefined | set your own logic for onChange method, it triggers on any change |
6261
| horizontal | boolean | false | make the button horizontal design |
6362
| initial | number | 0 | set the initial value for the counter input |
63+
| onChange | function | undefined | set your own logic for onChange method, it triggers on any change |
6464
| onChangeText | function | undefined | it triggers when the TextInput changes |
6565
| onIncreasePress | function | undefined | it triggers when the increase button is pressed |
6666
| onDecreasePress | function | undefined | it triggers when the decrease button is pressed |

lib/CounterInput.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export interface ICounterInputProps {
2929
onIncreasePress?: (counter: number) => void;
3030
onDecreasePress?: (counter: number) => void;
3131
onChangeText?: (counter: number | string) => void;
32-
onChange: (counter: number | string) => void;
32+
onChange: (counter: number) => void;
3333
}
3434

3535
interface IState {
@@ -67,7 +67,7 @@ export default class CounterInput extends React.Component<
6767

6868
handleOnChangeText = (text: string) => {
6969
const { onChange, onChangeText } = this.props;
70-
let _number: number | string = parseInt(text) || "";
70+
let _number: number = parseInt(text) || 0;
7171
this.setState({ counter: _number }, () => {
7272
onChangeText && onChangeText(this.state.counter);
7373
onChange && onChange(this.state.counter);

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-counter-input",
3-
"version": "0.1.5",
3+
"version": "0.1.6",
44
"description": "Counter Input with fully customizable options for React Native",
55
"main": "./build/dist/CounterInput.js",
66
"repository": "[email protected]:WrathChaos/react-native-counter-input.git",

0 commit comments

Comments
 (0)