UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

27 lines (24 loc) • 1.05 kB
import { Children, Fragment, createContext, isValidElement } from "react"; import { Image, ScrollView, Text, TextInput, View } from "react-native-web"; const InsideContainer = createContext(false); const reactNativeChildren = new Set([ View, Text, Image, ScrollView, TextInput ].filter(Boolean)); function assertOneNativeChildren(children, owner) { for (const child of Children.toArray(children)) { if (child === null || child === void 0 || typeof child === "boolean") continue; if (typeof child === "string" || typeof child === "number") throw new Error(`${owner} takes SwiftUI children, not raw text or numbers`); if (!isValidElement(child)) continue; if (child.type === Fragment) { assertOneNativeChildren(child.props.children, owner); continue; } if (typeof child.type === "string" || reactNativeChildren.has(child.type)) throw new Error(`${owner} takes SwiftUI children; move React Native content into Swift.Slot`); } } export { InsideContainer, assertOneNativeChildren }; //# sourceMappingURL=containerChildren.mjs.map