Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,40 @@ function MultilineStyledTextInput({
);
}

function DynamicContentWidth() {
const [text, setText] = useState('');
const update = () => {
const randomNumber = Math.floor(Math.random() * 10);
setText(text + randomNumber);
};

return (
<View>
<Text>Uncontrolled:</Text>
<TextInput
placeholder="Type..."
style={{
fontSize: 16,
alignSelf: 'center',
backgroundColor: 'orange',
}}
/>
<Text>Controlled:</Text>
<TextInput
placeholder="..."
value={text}
onChangeText={setText}
style={{
fontSize: 16,
alignSelf: 'center',
backgroundColor: 'orange',
}}
/>
<Button title="Update controlled Input" onPress={update} />
</View>
);
}

module.exports = ([
{
title: 'Auto-focus & select text on focus',
Expand Down Expand Up @@ -1149,4 +1183,11 @@ module.exports = ([
);
},
},
{
title: 'Dynamic content width',
name: 'dynamicWidth',
render: function (): React.Node {
return <DynamicContentWidth />;
},
},
]: Array<RNTesterModuleExample>);