Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow to array style prop #2189

Merged
merged 2 commits into from
Jul 18, 2024

Conversation

heecheolman
Copy link
Contributor

@heecheolman heecheolman commented Dec 5, 2023

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
1 check passed
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