Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ interface IMaskedInputProps extends TextInputProps {
mask: string;
value?: string;
onTextChange?: OnTextChangeListener;
innerRef?: React.Ref<TextInput>
}

interface IMaskedInputState {
value: string;
}

export default class MaskedInput extends Component<IMaskedInputProps, IMaskedInputState> {
class MaskedInput extends Component<IMaskedInputProps, IMaskedInputState> {

private userInputProcessorFunction: InputProcessorFunction;

Expand Down Expand Up @@ -47,12 +48,17 @@ export default class MaskedInput extends Component<IMaskedInputProps, IMaskedInp
}

public render(): ReactNode {
let { mask, value, onTextChange, ...attributes } = this.props;
let { mask, value, onTextChange, innerRef, ...attributes } = this.props;
return (
<TextInput
value={this.state.value}
ref={innerRef}
onChangeText={(text) => this.onTextChange(text)}
{...attributes}/>
);
}
}

export default React.forwardRef<TextInput, IMaskedInputProps>(
(props, ref) => <MaskedInput innerRef={ref} {...props} />
);
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "react-native-masked-input-text",
"version": "1.0.11",
"description": "A typescript masked InputText for react-native",
"main": "index.tsx",
"main": "index.js",
"types": "index.d.ts",
"repository": "git@github.com:ProdutorAgro/react-native-masked-input-text.git",
"author": "Matheus Nogueira <matheus.nogueira@produtoragro.com.br>",
"license": "MIT",
Expand Down