Menu

Post image 1
Post image 2
1 / 2
0

Control SwiftUI and Compose State Synchronously with Worklets in Expo UI

DEV Community: expo·Dan·3 days ago
#lIMLDE2R
#dev#value#native#worklet#state#article
Reading 0:00
15s threshold

React Native developers have long dealt with the friction of bridging JavaScript with native UI threads. Every time you need to update native state, you send a message across the bridge, wait for the round-trip, and hope the user doesn't notice the delay. Expo UI in SDK 56 changes this with worklet integration. You can now control SwiftUI and Compose state directly on the UI thread, with zero JavaScript round-trips. Here's what that looks like: import { Host , TextInput , useNativeState } from ' @expo/ui ' ; export default function Screen () { const value = useNativeState ( '' ); return ( < Host matchContents > < TextInput value = { value } placeholder = " Type something " onChangeText = {( value ) => { ' worklet ' ; // Runs synchronously on the UI thread, on every keystroke. console .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More