How to combine a styles object with an inline style in React Native? Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of How to combine a styles object with an inline style in React Native? without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I am trying to combine an inline style transform: [{ rotate: '180deg'}] with an already existing styles object styles.buttonText without modifying the styles object. I have tried the following ways:

<Text style={{...styles.buttonText, transform: [{ rotate: '180deg'}]}}>^</Text>

and

<Text style={{...styles.buttonText, ...{transform: [{ rotate: '180deg'}]}}}>^</Text>

and

<Text style={Object.assign({}, styles.buttonText, {transform: [{ rotate: '180deg'}]})}>^</Text>

But I keep getting this same error message:

TypeError: In this environment the sources for assign MUST be an object. This error is a performance optimization and not spec compliant.

Does anyone know what is going on or how I can get this to work?

Answer

I got it to work with this:

<Text style={[styles.buttonText, {transform: [{ rotate: '180deg' }]}]}>^</Text>
We are here to answer your question about How to combine a styles object with an inline style in React Native? - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji