In react-native there is a new Pressable component that can take a function as a child:
<View>
<Pressable
onPress={() => {
setTimesPressed((current) => current + 1);
}}
style={({ pressed }) => [
{
backgroundColor: pressed
? 'rgb(210, 230, 255)'
: 'white'
},
styles.wrapperCustom
]}>
{({ pressed }) => (
<Text style={styles.text}>
{pressed ? 'Pressed!' : 'Press Me'}
</Text>
)}
</Pressable>
<View style={styles.logBox}>
<Text testID="pressable_press_console">{textLog}</Text>
</View>
</View>
When I try passing a clojurescript fn:
[react/pressable {:on-press on-submit}
(fn [^js props]
(let [pressed (when props
(.-pressed props))]
(println pressed)
[next-button pressed]))]
I get functions are not valid as a React child
Is there a way to use this component in cljs?The error appears because you need to return a react element from that function (reagent/as-element [next-button pressed])
instead of [next-button pressed]
same as with render props
Hi folks, Could you recommend a react data grid that you've successfully integrated with cljs ?
@geraldodev I already used this library and it works very well : https://devexpress.github.io/devextreme-reactive/react/grid/