[RN] Introduce initialValue prop to fix TextInputExamples

Summary:
Some of the examples relied on the fact that TextInput wasn't a controlled
component before.  This introduces a new `initialValue` prop which behaves the
way the `value` prop used to - that is, you could type without updating it and
it wouldn't get reset, thus acting as just an initial value - and switches the
examples to use it where appropriate.
This commit is contained in:
Spencer Ahrens
2015-07-22 14:03:32 -07:00
parent 49b55804b1
commit cec5360f1b
2 changed files with 20 additions and 9 deletions

View File

@@ -315,7 +315,7 @@ exports.examples = [
return (
<View>
<WithLabel label="true">
<TextInput password={true} style={styles.default} value="abc" />
<TextInput password={true} style={styles.default} defaultValue="abc" />
</WithLabel>
</View>
);
@@ -332,11 +332,11 @@ exports.examples = [
<View>
<TextInput
style={[styles.default, {color: 'blue'}]}
value="Blue"
defaultValue="Blue"
/>
<TextInput
style={[styles.default, {color: 'green'}]}
value="Green"
defaultValue="Green"
/>
</View>
);
@@ -383,7 +383,7 @@ exports.examples = [
<WithLabel label="clearTextOnFocus">
<TextInput
placeholder="text is cleared on focus"
value="text is cleared on focus"
defaultValue="text is cleared on focus"
style={styles.default}
clearTextOnFocus={true}
/>
@@ -391,7 +391,7 @@ exports.examples = [
<WithLabel label="selectTextOnFocus">
<TextInput
placeholder="text is selected on focus"
value="text is selected on focus"
defaultValue="text is selected on focus"
style={styles.default}
selectTextOnFocus={true}
/>