Skip to content

fix: allow to array style prop#2189

Merged
bohdanprog merged 2 commits into
software-mansion:mainfrom
heecheolman:fix-style-prop
Jul 18, 2024
Merged

fix: allow to array style prop#2189
bohdanprog merged 2 commits into
software-mansion:mainfrom
heecheolman:fix-style-prop

Conversation

@heecheolman

@heecheolman heecheolman commented Dec 5, 2023

Copy link
Copy Markdown
Contributor

Summary

  • Previously, styles in "Array" format were not being applied correctly.
  • Therefore, now ensure that styles in "Array" format are correctly applied using StyleSheet.flatten.

Before: The opacity attribute is not correctly applied in gStyle.

const gStyle = Object.assign({}, [{ opacity: 0.5 }]);
/* { 0: {opacity: 0.5 }} */

After: Now, the opacity attribute is correctly applied in gStyle.

const gStyle = StyleSheet.flatten([{ opacity: 0.5 }]);
/* { opacity: 0.5 } */
const gStyle = StyleSheet.flatten([{ opacity: 0.5 }, { backgroundColor: 'red' }]);
/* { opacity: 0.5, backgroundColor: 'red' } */

Test Plan

0 key is not allow to ViewStyle

What's required for testing (prerequisites)?

What are the steps to reproduce (after prerequisites)?

Compatibility

OS Implemented
iOS
Android

Checklist

  • I have tested this on a device and a simulator

@bohdanprog bohdanprog self-assigned this Jul 18, 2024
@bohdanprog bohdanprog requested a review from jakex7 July 18, 2024 09:15
@bohdanprog bohdanprog merged commit 74445cc into software-mansion:main Jul 18, 2024
jakex7 added a commit that referenced this pull request Jul 19, 2024
# Summary

Fix bug introduced in #2189, 
if `style` is not provided, then `StyleSheet.flatten` returns
`undefined`, and we're trying to access `transform` of it.

## Test Plan

Run `example` app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants