Skip to content

feat: add support for react compiler bundled native handlers#3024

Merged
isekovanic merged 1 commit intodevelopfrom
feat/react-compiler-support
Mar 17, 2025
Merged

feat: add support for react compiler bundled native handlers#3024
isekovanic merged 1 commit intodevelopfrom
feat/react-compiler-support

Conversation

@isekovanic
Copy link
Copy Markdown
Contributor

🎯 Goal

Starting from RN 0.77.0, some changes have been done to how the beta React Compiler feature resolves modules, specifically mutable exported variables.

Since most of our actual native handlers were exactly that, practically none of them were functioning (seeing weird stuff like no MessageList on stream-chat-expo applications running this, or getting errors when trying to upload images or other attachments).

This PR makes sure that the compiler does not try to optimize away used code and stores all of our NativeHandlers in a mutable object which is then later consumed. This way, registerNativeHandlers can properly mutate the object while the reference towards it stays the same and the compiler doesn't ignore it.

🛠 Implementation details

🎨 UI Changes

iOS
Before After
Android
Before After

🧪 Testing

☑️ Checklist

  • I have signed the Stream CLA (required)
  • PR targets the develop branch
  • Documentation is updated
  • New code is tested in main example apps, including all possible scenarios
    • SampleApp iOS and Android
    • Expo iOS and Android

@Stream-SDK-Bot
Copy link
Copy Markdown
Contributor

SDK Size

title develop branch diff status
js_bundle_size 467 KB 467 KB +26 B 🟢

Comment thread package/src/native.ts
export const isFileSystemAvailable = () => !!saveFile || !!deleteFile;
export const isAudioRecorderAvailable = () => !!Audio?.startRecording;
export const isSoundPackageAvailable = () => !!Sound.Player || !!Sound.initializeSound;
export const isImagePickerAvailable = () => !!NativeHandlers.takePhoto;
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.

These helpers can be directly imported, as they're using the referenced NativeHandlers object directly (and their return value will mutate with it)

@isekovanic isekovanic merged commit 6758d06 into develop Mar 17, 2025
5 checks passed
@isekovanic isekovanic deleted the feat/react-compiler-support branch March 17, 2025 13:41
@github-actions github-actions bot mentioned this pull request Mar 17, 2025
@stream-ci-bot
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 6.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants