/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow strict-local
*/
'use strict';
const React = require('react');
const {Image, Text, TouchableHighlight, View} = require('react-native');
function Basic(): React.Node {
return (
This text contains an inline blue view{' '}
and
an inline image . Neat,
huh?
);
}
function NestedTexts(): React.Node {
return (
This is the first row
This is a nested text
with a Red View
);
}
function ClippedByText(): React.Node {
return (
{/*
* Inline View
**/}
The inline view below is
taller than its Text parent and should be clipped.
This is an inline view
{/* Render a red border around the steelblue rectangle to make it clear how the inline view is being clipped */}
{/*
* Inline Image
**/}
The inline image below is
taller than its Text parent and should be clipped.
This is an inline image
);
}
type ChangeSizeState = {|
width: number,
|};
class ChangeImageSize extends React.Component {
state: ChangeSizeState = {
width: 50,
};
render(): React.Node {
return (
{
this.setState({width: this.state.width === 50 ? 100 : 50});
}}>
Change Image Width (width={this.state.width})
This is an
inline image
);
}
}
class ChangeViewSize extends React.Component {
state: ChangeSizeState = {
width: 50,
};
render(): React.Node {
return (
{
this.setState({width: this.state.width === 50 ? 100 : 50});
}}>
Change View Width (width={this.state.width})
This is an
inline view
);
}
}
class ChangeInnerViewSize extends React.Component {
state: ChangeSizeState = {
width: 50,
};
render(): React.Node {
return (
{
this.setState({width: this.state.width === 50 ? 100 : 50});
}}>
{/* When updating `state.width`, it's important that the only thing that
changes is the width of the pink inline view. When we do this, we
demonstrate a bug in RN Android where the pink view doesn't get
rerendered and remains at its old size. If other things change
(e.g. we display `state.width` as text somewhere) it could circumvent
the bug and cause the pink view to be rerendered at its new size. */}
Change Pink View Width
This is an
inline view
);
}
}
module.exports = {
Basic,
NestedTexts,
ClippedByText,
ChangeImageSize,
ChangeViewSize,
ChangeInnerViewSize,
};