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

Disallow functions as value of style prop in libs related to React Native #2014

Merged
merged 6 commits into from
Sep 20, 2020

Conversation

Andarist
Copy link
Member

Partially addresses #1955

@changeset-bot
Copy link

changeset-bot bot commented Sep 14, 2020

🦋 Changeset is good to go

Latest commit: 0fd8094

We got this.

This PR includes changesets to release 3 packages
Name Type
@emotion/native Major
@emotion/primitives Major
@emotion/primitives-core Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codesandbox-ci
Copy link

codesandbox-ci bot commented Sep 14, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 0fd8094:

Sandbox Source
Emotion Configuration

@@ -54,6 +54,11 @@ export function createStyled(

let stylesWithStyleProp = styles
if (props.style) {
if (typeof props.style === 'function') {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternatively, we could resolve those with theme - the main problem was that those were resolved with props which didn't even match css prop signatures

I'm mostly interested in avoiding any other solutions from being breaking changes in v11 - we don't have to have a final solution for this problem right now, we only need to make sure that we can implement a final solution within v11 line. But also - I'm not super interested in working on any improvements here 🤷‍♂️ The community must step up if they want anything from the libs related to React Native.

Copy link
Member

@emmatown emmatown Sep 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still allows functions here doesn't it because I assume you can pass in an array with a function in it and it'll be called?

Why don't we do newProps.style = [emotionStyles, props.style]?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so that way RN should just resolve on its own the array and we omit the props.style from being resolved by Emotion? that would be sweet!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've used your advice and changes the code accordingly. Had to update snapshots and I've decided to use actual web implementation of react-primitives in tests so things get tested in more e2e manner - with the previous mock array got forwarded to the native (JS)DOM's style prop which didn't look OK.

@@ -13,7 +13,7 @@
],
"license": "MIT",
"dependencies": {
"css-to-react-native": "^2.2.1"
"css-to-react-native": "^3.0.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a changeset for this, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

@Andarist Andarist merged commit 95ea283 into next Sep 20, 2020
@Andarist Andarist deleted the disallow-style-funcs branch September 20, 2020 04:45
@github-actions github-actions bot mentioned this pull request Nov 10, 2020
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