From cf926a1329a8cd6921e9799877883ac1fbc26fbb Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Wed, 24 Apr 2024 14:54:08 -0700 Subject: [PATCH] decouple commit from mount on Android (#44236) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44236 ## Changelog: [Android] [Fixed] - fix a case when view preallocation or props forwarding on Android lead to dropped props update # What does this fix This fixes a bug where prop change is not delivered to Android mounting layer if the prop change was initiated from state update inside of `useLayoutEffect`, `componentDidMount` or `componentDidUpdate`. This affects android only and when batched rendering is enabled. There are two root causes of this problem: 1. View preallocation on Android: https://fburl.com/code/r62p3vot 2. Prop forwarding on Android: https://fburl.com/code/644f1ppk Minimal repro : ``` import React, {useLayoutEffect, useState} from 'react'; import {Button, SafeAreaView, View} from 'react-native'; function Foo() { const [bgColor, setBgColor] = React.useState('red'); useLayoutEffect(() => { console.log('useLayoutEffect'); setBgColor('blue'); }, []); return ( ); } function RNTesterApp() { const [show, setShow] = useState(false); return (