tongyy / react-native-draggable

Draggable Item
MIT License
312 stars 89 forks source link

Disable/Enable on the fly #98

Closed Crashtor closed 3 years ago

Crashtor commented 3 years ago

I'm trying to disable Draggable from a child <View>. However, it doesn't update on the fly.

<Draggable disabled={disabled.dis}>
        <View onTouchStart={() => updateDisabled() } ></View>
</Draggable>
const updateDisabled = () => {
    disabled = {dis: disabled.dis == false ? true : false}
}

Any suggestions as to how I can update on the fly?

Thanks

Crashtor commented 3 years ago

it worked with useState

const [disabled, setDisabled] = useState(false)

<Draggable disabled={disabled}/>

<Pressable onPress={() => setDisabled(true)} />