Skip to content

[expo-ui] Add compose modifiers.#38630

Merged
aleqsio merged 11 commits intomainfrom
@aleqsio/compose-modifiers
Aug 14, 2025
Merged

[expo-ui] Add compose modifiers.#38630
aleqsio merged 11 commits intomainfrom
@aleqsio/compose-modifiers

Conversation

@aleqsio
Copy link
Copy Markdown
Contributor

@aleqsio aleqsio commented Aug 7, 2025

Why

Mirroring the same work for iOS (also the same API) by @Kudo.

How

Used SharedRefs and invoking JavaScriptFunctions for clickable. This makes the modifiers reusable across different packages.

Test Plan

Tested in BareExpo by placing modifiers on various components.

Checklist

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Aug 7, 2025
@expo-bot
Copy link
Copy Markdown
Collaborator

expo-bot commented Aug 7, 2025

The Pull Request introduced fingerprint changes against the base commit: 323acc7

Fingerprint diff
[
  {
    "op": "changed",
    "beforeSource": {
      "type": "dir",
      "filePath": "../../packages/expo-ui/android",
      "reasons": [
        "expoAutolinkingAndroid"
      ],
      "hash": "11d9d951b8df5128281c9229e323c88e8113b0e7"
    },
    "afterSource": {
      "type": "dir",
      "filePath": "../../packages/expo-ui/android",
      "reasons": [
        "expoAutolinkingAndroid"
      ],
      "hash": "69b9a75f3920b4da4e783ce887f135fb33be4ec4"
    }
  }
]

Generated by PR labeler 🤖

@aleqsio aleqsio force-pushed the @aleqsio/compose-modifiers branch from 1a90cc6 to 3568e22 Compare August 11, 2025 13:38
@aleqsio aleqsio changed the title Add compose modifiers draft [expo-ui] Add compose modifiers. Aug 11, 2025
@aleqsio aleqsio requested review from Kudo and lukmccall August 11, 2025 13:59
@aleqsio aleqsio marked this pull request as ready for review August 11, 2025 14:00
Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Aug 11, 2025
@github-actions
Copy link
Copy Markdown
Contributor

Subscribed to pull request

File Patterns Mentions
packages/expo-ui/** @behenate

Generated by CodeMention

Copy link
Copy Markdown
Contributor

@Kudo Kudo left a comment

Choose a reason for hiding this comment

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

promising work! mostly great and the only comment is to have the createModifiers helper. then we can merge it. let's taste the modifiers implementation between SharedRef and array after merge

systemImage,
onButtonPressed: onPress,
// @ts-expect-error
modifiers: props.modifiers?.map((m) => m.__expo_shared_object_id__),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
modifiers: props.modifiers?.map((m) => m.__expo_shared_object_id__),
modifiers: createModifiers(props.modifiers),

maybe create a helper like createModifiers that to prevent exposing the shared object internal __expo_shared_object_id__ and the @ts-expect-error everywhere

function createModifiers(modifiers: ExpoModifiers[] | null) {
  // @ts-expect-error
  return modifiers?.map((m) => m.__expo_shared_object_id__),
}

Copy link
Copy Markdown
Contributor Author

@aleqsio aleqsio Aug 13, 2025

Choose a reason for hiding this comment

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

I thought about it but it's not modifier specific – we use it in more places/modules.

I'd be open to adding sharedObjectToProp to EMC – @lukmccall wdyt?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if we were not moving it to sharedObjectToProp. the current modifiers?.map((m) => m.__expo_shared_object_id__) is not scalable for 3rd party modifiers. having the createModifiers helper in expo-ui would help a little at least

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hmm, we can support any modifiers like that, but anytime you write a component that accepts SO as a prop you need this magic line. We should fix this in core at some point...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

alright since you have some idea to solve the problem in mind, then it makes sense to me. we can follow up later in a separate pr

@aleqsio aleqsio merged commit 805250d into main Aug 14, 2025
9 checks passed
@aleqsio aleqsio deleted the @aleqsio/compose-modifiers branch August 14, 2025 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot: fingerprint changed bot: passed checks ExpoBot has nothing to complain about

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants