Skip to content

docs: fix Flow spec examples that Codegen rejects in the Native Modules and Native Components guides - #5354

Open
Mosugar wants to merge 1 commit into
react:mainfrom
Mosugar:docs/fix-flow-spec-examples
Open

Mosugar wants to merge 1 commit into
react:mainfrom
Mosugar:docs/fix-flow-spec-examples

Conversation

@Mosugar

@Mosugar Mosugar commented Nov 30, 2026

Copy link
Copy Markdown

Requested by mosugar · project thread

Summary

The Flow tabs of two New Architecture guides have spec files that Codegen rejects, so readers who pick Flow and copy the example get an error before any native code runs.

Native Components (fabric-native-components.md): the RCTWebViewNativeComponent.js spec writes the optional handler as BubblingEventHandler<WebViewScriptLoadedEvent>?. A trailing ? isn't valid Flow, so the file fails to parse:

Syntax error in RCTWebViewNativeComponent.js: Unexpected token `?`, expected the token `,` (13:78)

Fix: use Flow's maybe type, ?CodegenTypes.BubblingEventHandler<WebViewScriptLoadedEvent>. I also used , separators like the other Flow examples, changed the code fence from ts to flow, and removed a stray : after the title.

Native Modules (turbo-native-modules.md): the NativeLocalStorage.js spec imports TurboModule twice, once as a type and once as a value (Identifier 'TurboModule' is already declared). It also never calls TurboModuleRegistry, so Codegen stops with:

Module NativeLocalStorage: Unused NativeModule spec. Please load the NativeModule by calling TurboModuleRegistry.get<Spec>('<moduleName>').

Fix: drop the duplicate value import and add the same export default TurboModuleRegistry.getEnforcing<Spec>('NativeLocalStorage') that the TypeScript tab already has.

I changed docs/ and website/versioned_docs/version-0.88/ so the fix shows on the current site.

How I checked it

I extracted both Flow snippets before and after the change and ran them through @react-native/codegen's FlowParser.parseFile. The originals fail with the errors above. The fixed files parse and produce the CustomWebView component schema and the NativeLocalStorage module schema. Every other Flow block in docs/ already parses with hermes-parser.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SfhAdkfsSyVJ2HsRVtzmiC

…e and component guides

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SfhAdkfsSyVJ2HsRVtzmiC
@meta-cla

meta-cla Bot commented Nov 30, 2026

Copy link
Copy Markdown

Hi @Mosugar!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

This branch has not been deployed

No deployments
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