diff --git a/src/components/Button.ts b/src/components/Button.ts index aef20f3..5da84c5 100644 --- a/src/components/Button.ts +++ b/src/components/Button.ts @@ -9,7 +9,7 @@ import { getBackend } from "../backends/index"; declare global { namespace JSX { interface IntrinsicElements { - BUTTON: React.PropsWithChildren + BUTTON: React.PropsWithChildren; } } } @@ -28,7 +28,7 @@ export default (p: Props) => { }; const defaultProps = { style: {}, - onPress: () => { }, + onPress: () => {}, title: "Button" }; @@ -52,6 +52,11 @@ export default (p: Props) => { const containerProps = Container( child => { + if (child.type === "text") + throw new Error( + "Button takes no children. If you are trying to set the title, use the title prop." + ); + child.element.setParent(element); if (child.node) { yogaProps.node.insertChild(child.node, yogaProps.node.getChildCount()); diff --git a/src/components/Image.ts b/src/components/Image.ts index 959b074..4dfa44a 100644 --- a/src/components/Image.ts +++ b/src/components/Image.ts @@ -30,7 +30,7 @@ interface ImageStyle extends React.CSSProperties { declare global { namespace JSX { interface IntrinsicElements { - IMAGE: Props + IMAGE: Props; } } } @@ -124,6 +124,8 @@ export default (p: Props) => { style: (style: ImageStyle) => { if (style.resizeMode) { resizeMode.r = style.resizeMode; + } else { + resizeMode.r = "cover"; } element.setStyleSheet(style); yogaProps.applyYogaStyle(style); diff --git a/src/components/Root.ts b/src/components/Root.ts index aa0607d..83b22c1 100644 --- a/src/components/Root.ts +++ b/src/components/Root.ts @@ -1,7 +1,7 @@ import propChecker from "../utils/propChecker"; import { disconnectDevtools } from "../devtools"; import { Container } from "./Container"; -import { getBackend } from '../backends/index' +import { getBackend } from "../backends/index"; import { Component } from "./Base"; export interface Root { @@ -13,14 +13,14 @@ export default (props: {}) => { const propTypes = {}; const defaultProps = {}; - const AppElement = getBackend()["AppElement"] + const AppElement = getBackend()["AppElement"]; const element = new AppElement(); props = propChecker(props, propTypes, defaultProps, "Root"); const containerProps = Container( - () => { }, - () => { } + () => {}, + () => {} ); const quit = () => { @@ -35,7 +35,13 @@ export default (props: {}) => { const interval = setInterval(() => { if (containerProps.children && containerProps.children.length) { for (let i = 0; i < containerProps.children[0].children.length; i++) { - const closed = containerProps.children[0].children[i].element.getClosed(); + if (!containerProps.children[0].children[i].element.getClosed) + throw new Error( + "Could not find Window or App. Did you forget to define one?" + ); + const closed = containerProps.children[0].children[ + i + ].element.getClosed(); if (!closed) { element.runLoop(); return;