git.iko.soy/rowtype-yoga/purescript-yoga-react-native
on main help sign in
WIP: React Native bindings development
commit33fd46323e64a4f60898d44f90cd45ce50376af6 authorMark <mark.eibes@gmail.com> dateMon 16 Feb 2026, 23:01 (7 months ago) parentc5df824
7 files changed+24−11
example-macos/src/Demo/AiMl.purs+1−1 example-macos/src/Demo/Chat.purs+2−2 example-macos/src/Demo/SystemServices.purs+1−1 example-macos/src/Demo/TextEditing.purs+1−1 example-macos/src/Demo/WebBrowser.purs+2−2 src/Yoga/React/Native/MacOS/TextField.js+14−1 src/Yoga/React/Native/MacOS/TextField.purs+3−3
example-macos/src/Demo/AiMl.purs+1−1
@@ -94,7 +94,7 @@ naturalLanguageDemo = component "NaturalLanguageDemo" \dp -> React.do
9494 , nativeTextField
9595 { text: txt
9696 , placeholder: "Enter text to analyze..."
97− , onChangeText: E.onString "text" setTxt
97+ , onChangeText: setTxt
9898 , style: Style.style { height: 24.0 } <> tw "mb-2"
9999 }
100100 , view { style: tw "flex-row items-center mb-2" }
example-macos/src/Demo/Chat.purs+2−2
@@ -361,8 +361,8 @@ chatDemo = component "ChatDemo" \dp -> React.do
361361 , placeholder: "Message..."
362362 , search: false
363363 , rounded: true
364− , onChangeText: E.onString "text" \t -> setInputText (replaceEmoji t)
365− , onSubmit: E.onString "text" \t -> sendMessage rid t
364+ , onChangeText: \t -> setInputText (replaceEmoji t)
365+ , onSubmit: \t -> sendMessage rid t
366366 , style: tw "flex-1" <> Style.style { height: 28.0 }
367367 }
368368 , nativeButton
example-macos/src/Demo/SystemServices.purs+1−1
@@ -189,7 +189,7 @@ speechDemo = component "SpeechDemo" \dp -> React.do
189189 , nativeTextField
190190 { text: txt
191191 , placeholder: "Text to speak..."
192− , onChangeText: E.onString "text" setTxt
192+ , onChangeText: setTxt
193193 , style: Style.style { height: 24.0 } <> tw "mb-2"
194194 }
195195 , view { style: tw "flex-row items-center mb-4" }
example-macos/src/Demo/TextEditing.purs+1−1
@@ -24,7 +24,7 @@ textFieldDemo = component "TextFieldDemo" \dp -> React.do
2424 { placeholder: "Type something..."
2525 , search: true
2626 , text: txt
27− , onChangeText: E.onString "text" setTxt
27+ , onChangeText: setTxt
2828 , style: Style.style { height: 24.0 }
2929 }
3030 , if txt == "" then mempty
example-macos/src/Demo/WebBrowser.purs+2−2
@@ -25,8 +25,8 @@ webViewDemo = component "WebViewDemo" \dp -> React.do
2525 { text: urlBar
2626 , placeholder: "Enter URL..."
2727 , search: false
28− , onChangeText: E.onString "text" setUrlBar
29− , onSubmit: E.onString "text" setUrl
28+ , onChangeText: setUrlBar
29+ , onSubmit: setUrl
3030 , style: Style.style { height: 24.0, marginBottom: 8.0 }
3131 }
3232 , nativeWebView
src/Yoga/React/Native/MacOS/TextField.js+14−1
@@ -1,2 +1,15 @@
1+import React from "react";
12import { requireNativeComponent } from "react-native";
2−export const textFieldImpl = requireNativeComponent("NativeTextField");
3+
4+const NativeTextField = requireNativeComponent("NativeTextField");
5+
6+export const textFieldImpl = React.forwardRef((props, ref) => {
7+ const nativeProps = { ...props };
8+ if (typeof props.onChangeText === "function") {
9+ nativeProps.onChangeText = (e) => props.onChangeText(e.nativeEvent.text)();
10+ }
11+ if (typeof props.onSubmit === "function") {
12+ nativeProps.onSubmit = (e) => props.onSubmit(e.nativeEvent.text)();
13+ }
14+ return React.createElement(NativeTextField, { ...nativeProps, ref });
15+});
src/Yoga/React/Native/MacOS/TextField.purs+3−3
@@ -1,7 +1,7 @@
11module Yoga.React.Native.MacOS.TextField (nativeTextField, NativeTextFieldAttributes) where
22
3+import Effect (Effect)
34import React.Basic (ReactComponent)
4−import React.Basic.Events (EventHandler)
55import Yoga.React.Native.Attributes (BaseAttributes)
66import Yoga.React.Native.Internal (FFINativeComponent_, createNativeElement_)
77
@@ -16,6 +16,6 @@ type NativeTextFieldAttributes = BaseAttributes
1616 , secure :: Boolean
1717 , search :: Boolean
1818 , rounded :: Boolean
19− , onChangeText :: EventHandler
20− , onSubmit :: EventHandler
19+ , onChangeText :: String -> Effect Unit
20+ , onSubmit :: String -> Effect Unit
2121 )