Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native stylesheet merge: Spread types may only be created from object types

I'm trying to merge an existing style with my extra styling in React Native's regular StyleSheet.create method:

const styles = StyleSheet.create({
    blurView:{
        ...StyleSheet.absoluteFill,
        borderRadius: 24
    },

});

However I'm getting the following error on line ...StyleSheet.absoluteFill:

Spread types may only be created from object types.

What am I doing wrong? I know I can pass an array into style prop, but I'm just curious why this isn't working.

like image 815
Can Poyrazoğlu Avatar asked Oct 28 '25 12:10

Can Poyrazoğlu


1 Answers

Changing StyleSheet.absoluteFill to StyleSheet.absoluteFillObject fixed the issue. Apparently spread operator doesn't play well with registered styles.

like image 104
Can Poyrazoğlu Avatar answered Oct 31 '25 02:10

Can Poyrazoğlu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!