1- import { useState } from 'react' ;
1+ import { useState , useEffect } from 'react' ;
22import {
33 View ,
44 StyleSheet ,
@@ -391,6 +391,36 @@ function CombinedDemo() {
391391 ) ;
392392}
393393
394+ function StyleReRenderDemo ( ) {
395+ const [ moved , setMoved ] = useState ( false ) ;
396+ const [ opacity , setOpacity ] = useState ( 0.5 ) ;
397+
398+ // Re-render style every 500ms to simulate frequent React re-renders
399+ useEffect ( ( ) => {
400+ const interval = setInterval ( ( ) => {
401+ setOpacity ( ( o ) => ( o === 0.5 ? 0.8 : 0.5 ) ) ;
402+ } , 500 ) ;
403+ return ( ) => clearInterval ( interval ) ;
404+ } , [ ] ) ;
405+
406+ return (
407+ < Section title = "Style Re-render Stress Test" >
408+ < Text style = { styles . reRenderHint } >
409+ Style opacity toggles every 500ms while transform animates
410+ </ Text >
411+ < EaseView
412+ animate = { { translateX : moved ? 150 : 0 , scale : moved ? 1.2 : 1 } }
413+ transition = { { type : 'spring' , damping : 12 , stiffness : 120 , mass : 1 } }
414+ style = { [ styles . box , { opacity } ] }
415+ />
416+ < Button
417+ label = { moved ? 'Back' : 'Move' }
418+ onPress = { ( ) => setMoved ( ( v ) => ! v ) }
419+ />
420+ </ Section >
421+ ) ;
422+ }
423+
394424function DemosScreen ( ) {
395425 return (
396426 < ScrollView contentContainerStyle = { styles . scrollContent } >
@@ -415,6 +445,7 @@ function DemosScreen() {
415445 < BackgroundColorDemo />
416446 < CustomEasingDemo />
417447 < CombinedDemo />
448+ < StyleReRenderDemo />
418449 </ ScrollView >
419450 ) ;
420451}
@@ -467,6 +498,11 @@ const styles = StyleSheet.create({
467498 fontSize : 13 ,
468499 marginBottom : 12 ,
469500 } ,
501+ reRenderHint : {
502+ color : '#8888aa' ,
503+ fontSize : 13 ,
504+ marginBottom : 12 ,
505+ } ,
470506 interruptRow : {
471507 flexDirection : 'row' ,
472508 alignItems : 'center' ,
0 commit comments