use-dom

Run web code in React Native apps using Expo DOM components.

2|Updated Oct 18, 2024
One-click install
npx skills add https://github.com/carlos3g/react-native-playground --skill use-dom-carlos3g
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: use-dom
Source: https://github.com/carlos3g/react-native-playground/tree/main/.agents/skills/use-dom
Command: npx skills add https://github.com/carlos3g/react-native-playground --skill use-dom-carlos3g

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill allows you to use Expo DOM components to run web code on native platforms and on the web, making it easier to migrate and integrate web code into native applications.

Core Features & Use Cases

  • Cross-Platform Compatibility: Use web-only libraries like recharts, react-syntax-highlighter, and any React web library on native platforms without modification.
  • Incremental Migrations: Gradually move existing React web components to native without rewriting the entire codebase.
  • Complex Layouts: Utilize CSS features and complex HTML/CSS layouts not available in React Native.
  • Embedding Content: Embed external content that requires a browser context, like iframes or embeds.
  • Web Graphics APIs: Access Canvas or WebGL, web graphics APIs not available natively.
  • Native Integration: Pass async functions as props to expose native functionality to the DOM component.
  • Use Case: Convert a React web chart to a native component by using the DOM components feature to render it in a webview.

Quick Start

Create a new file with the 'use dom'; directive and import the web library you want to use in your React component.

Frequently Asked Questions about use-dom

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use web libraries in React Native without rewriting components?

To use web libraries in React Native, you can use Expo DOM components to execute web code inside a webview on native platforms. This allows you to render web-only libraries like charts or syntax highlighters without modifying the original React web code.

What is the best way to migrate a React web app to native incrementally?

Migrating a React web app to native incrementally involves using Expo DOM components to run existing web code on native platforms. You can gradually move web components to native without rewriting the entire codebase by utilizing the 'use dom' directive in component files.

Can I use complex CSS layouts and Canvas in React Native?

Yes, you can use complex CSS layouts and Canvas in React Native by rendering web code through Expo DOM components. This approach provides access to web graphics APIs and CSS features that are not natively available in the standard React Native environment.

Does Expo DOM components support passing native functions as props?

Yes, Expo DOM components support passing async functions as props to expose native functionality to the DOM component. This native integration allows the web code running inside the webview to communicate with and trigger native features on the device.

How do I start using Expo DOM components in my project?

To start using Expo DOM components, create a new file with the 'use dom' directive and import the web library you want to use in your React component. You will also need to handle the 'dom' prop for proper configuration of the component.