Fork me on GitHub
#reagent
<
2020-10-21
>
yenda14:10:45

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?

ferossgp15:10:16

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

👍 3
geraldodev19:10:13

Hi folks, Could you recommend a react data grid that you've successfully integrated with cljs ?