UNPKG

one

Version:

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

44 lines (41 loc) • 1.57 kB
import { Children, Fragment, createContext, isValidElement } from "react"; import { Image, ScrollView, Text, TextInput, View } from "react-native"; var InsideContainer = createContext(false); var reactNativeChildren = new Set([ View, Text, Image, ScrollView, TextInput ].filter(Boolean)); function assertOneNativeChildren(children, owner) { var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0; try { for (var _iterator = Children.toArray(children)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { var child = _step.value; 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`); } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally { try { if (!_iteratorNormalCompletion && _iterator.return != null) { _iterator.return(); } } finally { if (_didIteratorError) { throw _iteratorError; } } } } export { InsideContainer, assertOneNativeChildren }; //# sourceMappingURL=containerChildren.native.js.map