reagent

A minimalistic ClojureScript interface to React.js http://reagent-project.github.io/
2020-08-07T09:11:59.147200Z

Hi, i’ve build an expo app and want to extend it with some drag-and-drop features. My current approach is using the PanResponder. Can someone give me a hint or link to the documentation how I can integrate code like this with reagent? (Especially the useRef hook)

import React, { useRef } from "react";
import { Animated, View, StyleSheet, PanResponder, Text } from "react-native";

export default function App() {
  const pan = useRef(new Animated.ValueXY()).current;

  const panResponder = useRef(
    PanResponder.create({
      onMoveShouldSetPanResponder: () => true,
      onPanResponderGrant: () => {
        pan.setOffset({
          x: pan.x._value,
          y: pan.y._value
        });
      },
      onPanResponderMove: Animated.event(
        [
          null,
          { dx: pan.x, dy: pan.y }
        ]
      ),
      onPanResponderRelease: () => {
        pan.flattenOffset();
      }
    })
  ).current;

  return (
    <View style={styles.container}>
      <Text style={styles.titleText}>Drag this box!</Text>
      <Animated.View
        style={{
          transform: [{ translateX: pan.x }, { translateY: pan.y }]
        }}
        {...panResponder.panHandlers}
      >
        <View style={styles.box} />
      </Animated.View>
    </View>
  );
}
Thx in advance

2020-08-10T13:58:42.161Z

I’ve solved this and a have working solution. If someone interested -> PM