11import React , { forwardRef } from "react" ;
2- import { Platform , PressableProps , TextStyle } from "react-native" ;
2+ import {
3+ Platform ,
4+ PressableProps ,
5+ PressableStateCallbackType ,
6+ TextStyle ,
7+ } from "react-native" ;
38
49import { RenderPropType } from "../../index" ;
510import { Box , Text , Touchable } from "../../primitives" ;
@@ -134,7 +139,7 @@ const RNButton: React.FC<Partial<ButtonProps>> = forwardRef<
134139 iconStyle : tailwind . style ( cx ( buttonTheme . size [ size ] ?. prefix ) ) ,
135140 } )
136141 ) : (
137- < ButtonPrefix size = { size } > { prefix } </ ButtonPrefix >
142+ < ButtonPrefix size = { size } > { prefix as React . ReactNode } </ ButtonPrefix >
138143 ) ;
139144
140145 const prefixEl =
@@ -168,7 +173,7 @@ const RNButton: React.FC<Partial<ButtonProps>> = forwardRef<
168173 iconStyle : tailwind . style ( cx ( buttonTheme . size [ size ] ?. suffix ) ) ,
169174 } )
170175 ) : (
171- < ButtonSuffix size = { size } > { suffix } </ ButtonSuffix >
176+ < ButtonSuffix size = { size } > { suffix as React . ReactNode } </ ButtonSuffix >
172177 ) ;
173178
174179 const suffixEl = loading ? (
@@ -185,50 +190,52 @@ const RNButton: React.FC<Partial<ButtonProps>> = forwardRef<
185190 < > { _suffix } </ >
186191 ) ;
187192
188- const defaultChildren = iconOnly ? (
189- < Box
190- style = { [
191- tailwind . style (
192- cx (
193- buttonTheme . size [ size ] ?. icon ,
194- loading ? buttonTheme . loading . children : "" ,
193+ const defaultChildren = (
194+ iconOnly ? (
195+ < Box
196+ style = { [
197+ tailwind . style (
198+ cx (
199+ buttonTheme . size [ size ] ?. icon ,
200+ loading ? buttonTheme . loading . children : "" ,
201+ ) ,
195202 ) ,
196- ) ,
197- { aspectRatio : iconAspectRatio } ,
198- ] }
199- >
200- { /* @ts -ignore */ }
201- { React . cloneElement ( iconOnly , {
202- color : tailwind . getColor (
203- isButtonDisabled
204- ? buttonTheme . themeColor [ themeColor ] ?. [ variant ] ?. icon . disabled
205- : buttonTheme . themeColor [ themeColor ] ?. [ variant ] ?. icon . default ,
206- ) ,
207- } ) }
208- </ Box >
209- ) : typeof props . children === "string" ? (
210- < Text
211- adjustsFontSizeToFit
212- allowFontScaling = { false }
213- selectable = { false }
214- style = { [
215- tailwind . style (
216- cx (
217- buttonTheme . size [ size ] ?. text ,
218- buttonTheme . themeColor [ themeColor ] ?. [ variant ] ?. text . default ,
203+ { aspectRatio : iconAspectRatio } ,
204+ ] }
205+ >
206+ { /* @ts -ignore */ }
207+ { React . cloneElement ( iconOnly , {
208+ color : tailwind . getColor (
219209 isButtonDisabled
220- ? buttonTheme . themeColor [ themeColor ] ?. [ variant ] ?. text . disabled
221- : "" ,
210+ ? buttonTheme . themeColor [ themeColor ] ?. [ variant ] ?. icon . disabled
211+ : buttonTheme . themeColor [ themeColor ] ?. [ variant ] ?. icon . default ,
222212 ) ,
223- ) ,
224- styleAdapter ( textStyle ) ,
225- ] }
226- >
227- { props . children }
228- </ Text >
229- ) : (
230- props . children
231- ) ;
213+ } ) }
214+ </ Box >
215+ ) : typeof props . children === "string" ? (
216+ < Text
217+ adjustsFontSizeToFit
218+ allowFontScaling = { false }
219+ selectable = { false }
220+ style = { [
221+ tailwind . style (
222+ cx (
223+ buttonTheme . size [ size ] ?. text ,
224+ buttonTheme . themeColor [ themeColor ] ?. [ variant ] ?. text . default ,
225+ isButtonDisabled
226+ ? buttonTheme . themeColor [ themeColor ] ?. [ variant ] ?. text . disabled
227+ : "" ,
228+ ) ,
229+ ) ,
230+ styleAdapter ( textStyle ) ,
231+ ] }
232+ >
233+ { props . children }
234+ </ Text >
235+ ) : (
236+ props . children
237+ )
238+ ) as React . ReactNode ;
232239
233240 const iconOnlyEl = loading ? (
234241 < ButtonFullWidthSpinner
@@ -259,7 +266,7 @@ const RNButton: React.FC<Partial<ButtonProps>> = forwardRef<
259266
260267 return (
261268 < Touchable
262- style = { touchState => {
269+ style = { ( touchState : PressableStateCallbackType ) => {
263270 return [
264271 tailwind . style (
265272 cx (
0 commit comments