Skip to content

Fix fatal error booting screens without a mount() method - #5

Open
siddiqar wants to merge 1 commit into
NativePHP:mainfrom
siddiqar:fix/web-boot-mount-lifecycle
Open

siddiqar wants to merge 1 commit into
NativePHP:mainfrom
siddiqar:fix/web-boot-mount-lifecycle

Conversation

@siddiqar

Copy link
Copy Markdown

What

WebScreenRunner::boot() invoked $component->mount() directly. Core's NativeComponent deliberately declares no mount(); it exposes the guarded mountComponent() entrypoint instead (a no-op when the component has no mount(), and route-binding + DI when it does), which NativeRouter also uses on device. Any screen without a mount() method therefore fatals in the browser:

Call to undefined method App\NativeComponents\Home::mount()
 at vendor/nativephp/web-ui/src/Protocol/WebScreenRunner.php:441

Reproduction

Route a screen that defines no mount():

Route::native('/', App\NativeComponents\Home::class);

GET / returns 500 before this change, 200 after.

Fix

Call mountComponent() instead (parity with NativeRouter::preloadStack() / the device run loop). Both mounting paths go through boot(), so this covers the initial GET and the {type: 'lazy'} update.

Also adds a CHANGELOG.md entry under [Unreleased].

Verification

  • Consuming app: nativephp/superstack starter, nativephp/mobile 4.6.0.
  • Browser (macOS): GET / renders <title>Super Stack</title>, HTTP 200; before the change, HTTP 500 with the trace above.

Notes

  • Per CONTRIBUTING, the behaviour test belongs in the nativephp/mobile suite (tests/Feature/Edge/, Web*). Happy to add/link it — let me know where you'd like it.
  • mountComponent() exists in nativephp/mobile 4.6.0. This package supports ^4.4; if mountComponent() is newer than that, a method_exists() guard would be warranted. Flagging in case you'd prefer the guarded form.

WebScreenRunner::boot() invoked $component->mount() directly. NativeComponent deliberately declares no mount(); it exposes the guarded mountComponent() entrypoint (no-op when mount() is absent, route-binding + DI when present), which NativeRouter also calls. Any screen without mount() — e.g. the Super Stack starter's Home — fatally errored with 'Call to undefined method ...::mount()'. Call mountComponent() instead, matching the device router.
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.

1 participant