Skip to content

Session Replay breaks icon layout #1193

@BogiKay

Description

@BogiKay

Describe the bug

When Session Replay SVG tracking is enabled, the babel plugin wraps every react-native-svg component in a <SessionReplayView.Privacy> View with style={{ flexShrink: 1 }}. React Native
defaults flexShrink to 0. This causes SVG icons to shrink below their specified dimensions inside constrained flex containers.

Replay Enabled Replay Disabled
Image Image

Reproduction steps

Example - https://github.com/BogiKay/dd-sdk-reactnative/tree/reply-flex-shrink-bug

  1. Install packages:

yarn add @datadog/mobile-react-native @datadog/mobile-react-native-session-replay @datadog/mobile-react-native-babel-plugin react-native-svg

  1. Enable SVG tracking in babel.config.js:
  module.exports = {
    presets: ['module:@react-native/babel-preset'],
    plugins: [
      ['@datadog/mobile-react-native-babel-plugin', {
        sessionReplay: { svgTracking: true },
      }],
    ],
  };
  1. Create an SVG icon:
  import Svg, { Path } from 'react-native-svg';

  const MyIcon () => (
    <Svg fill="none" viewBox="0 0 24 24">
      <Path fill="black" d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z" />
    </Svg>
  );
  1. Render inside a constrained flex row:

<View style={{ flexDirection: 'row', width: 80 }}>

Label

  1. The icon renders smaller than 24×24. Inspecting the bundle output shows the wrapper has style={{ flexShrink: 1 }}.

SDK logs

Expected behavior

Layout is unaffected

Affected SDK versions

3.1.1

Latest working SDK version

N/A

Did you confirm if the latest SDK version fixes the bug?

Yes

Integration Methods

Yarn

React Native Version

0.81.5

Package.json Contents

No response

iOS Setup

No response

Android Setup

No response

Device Information

No response

Other relevant information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions