3

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?

1 Answer 1

16

If you want to combine styles on a element you have to pass an array to the style property. The last item in the array will take precedence.

e.g:

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

see style docs

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.