-
Notifications
You must be signed in to change notification settings - Fork 8
feat(runtime,jest,bridge): add console forwarding and batched state updates #61
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
Conversation
|
@bheemreddy-samsara is attempting to deploy a commit to the Callstack Team on Vercel. A member of the Team first needs to authorize it. |
5f9bae7 to
ae5e7b8
Compare
…pdates Console Forwarding: - Forward console.log/warn/error/info/debug from device to Jest output - Add ConsoleEvent/ConsoleLevel types to BridgeEvents union - Preserve Error details (stack/message) in forwarded output - Fix %d printf placeholder to use Number() for decimals Type Improvements: - Remove type assertions in factory.ts with proper ConsoleEvent types - Add proper generic constraints for Harness.on/off methods - Import shared ConsoleEvent type in jest package Shared Utilities: - Extract batchedUpdate utility to avoid code duplication - Add resetRenderState helper for common state reset pattern - Simplify render/cleanup.ts using shared utilities
ae5e7b8 to
55a1412
Compare
| * Batches state updates to avoid act() warnings in React Native. | ||
| * Falls back to direct execution if unstable_batchedUpdates is unavailable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should not see 'act' warnings as this is a normal React Native app. Could you provide a code sample where it happens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect this is only happening on the old arch and not on the new arch since it has autobatching enabled. We'll try to provide a minimal repro soon.
V3RON
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you enable 'server.forwardClientLogs' via @react-native-harness/metro, you should see client_log events being reported by the Metro reporter in @react-native-harness/bundler-metro.
|
closing in favor of #63 |
Summary
unstable_batchedUpdatesto prevent React act() warnings during testingWhat changed
Bridge package (
packages/bridge/)ConsoleEventandConsoleLeveltypesConsoleEventtoBridgeEventsunionJest package (
packages/jest/)on/offmethods usingBridgeServerEventsstringtype in favor of typed event namesConsoleEventfrom bridge package instead of local definition%s,%d,%i,%o,%O,%j)%dto useNumber()(preserves decimals) vs%iusesparseInt()(integers only)Runtime package (
packages/runtime/)unstable_batchedUpdatesresetRenderState()helper for common state reset patternresetRenderState()helperbatchedUpdateandresetRenderStateutilitiesConsoleEventis inBridgeEventsErrordetails (stack/message) instead of serializing to{}Test plan
console.error(new Error('test'))