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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-prompt",
"version": "1.0.0",
"version": "1.0.1",
"description": "A cross-platform prompt component for React Native.",
"repository": {
"type": "git",
Expand Down
17 changes: 14 additions & 3 deletions src/Prompt.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component, PropTypes } from 'react';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import {
Modal,
Platform,
Expand Down Expand Up @@ -60,9 +61,18 @@ export default class Prompt extends Component {
this.setState({value: this.props.defaultValue});
}

componentWillReceiveProps(nextProps) {
/*componentWillReceiveProps(nextProps) {
const { visible, defaultValue } = nextProps;
this.setState({ visible, value:defaultValue });
if(visible !== this.props.visible && visible) {
this.setState({ visible, value: defaultValue });
}
}*/
static getDerivedStateFromProps(nextProps, prevState) {
const { visible, defaultValue } = nextProps;
if(visible !== nextProps.visible && visible) {
return { visible: defaultValue };
}
return null;
}

_onChangeText = (value) => {
Expand Down Expand Up @@ -114,6 +124,7 @@ export default class Prompt extends Component {
<TextInput
style={[styles.dialogInput, inputStyle]}
defaultValue={defaultValue}
value={this.state.value}
onChangeText={this._onChangeText}
placeholder={placeholder}
autoFocus={true}
Expand Down