Skip to content
Open
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: 4 additions & 2 deletions src/skeleton-placeholder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type SkeletonPlaceholderProps = {
* Determines width of the highlighted area
*/
shimmerWidth?: number;
testID?: string;
};

type SkeletonPlaceholderItemProps = ViewStyle & {
Expand All @@ -68,6 +69,7 @@ const SkeletonPlaceholder: React.FC<SkeletonPlaceholderProps> & {
direction = 'right',
borderRadius,
shimmerWidth,
testID,
}) => {
const [layout, setLayout] = React.useState<LayoutRectangle>();
const animatedValueRef = React.useRef(new Animated.Value(0));
Expand Down Expand Up @@ -125,13 +127,13 @@ const SkeletonPlaceholder: React.FC<SkeletonPlaceholderProps> & {
if (!enabled || !placeholders) return children;

if (!layout?.width || !layout.height)
return <View onLayout={(event) => setLayout(event.nativeEvent.layout)}>{placeholders}</View>;
return <View testID={testID} onLayout={(event) => setLayout(event.nativeEvent.layout)}>{placeholders}</View>;

// https://github.com/react-native-linear-gradient/react-native-linear-gradient/issues/358
// to make transparent gradient we need to use original color with alpha

return (
<MaskedView style={{height: layout.height, width: layout.width}} maskElement={placeholders}>
<MaskedView testID={testID} style={{height: layout.height, width: layout.width}} maskElement={placeholders}>
<View style={[StyleSheet.absoluteFill, {backgroundColor}]} />

{isAnimationReady && highlightColor !== undefined && transparentColor !== undefined && (
Expand Down