YanYuanFE / react-native-signature-canvas

:black_nib: React Native Signature Component based WebView Canvas for Android && IOS && expo
MIT License
417 stars 149 forks source link

Error when reading signature : ref.current.readSignature is not a function (it is undefined), #359

Open r083rt opened 4 months ago

r083rt commented 4 months ago

I just face this problem with my new project. My previous project that using the old RN version don't have this error.

TypeError: ref.current.readSignature is not a function (it is undefined), js engine: hermes

Here's my current info : System: OS: Windows 11 10.0.22621 CPU: "(16) x64 AMD Ryzen 7 5800H with Radeon Graphics " Memory: 1.28 GB / 15.41 GB Binaries: Node: version: 18.17.1 path: C:\Program Files\nodejs\node.EXE Yarn: version: 1.22.22 path: C:\Program Files\nodejs\yarn.CMD npm: version: 9.6.7 path: C:\Program Files\nodejs\npm.CMD Watchman: Not Found SDKs: Android SDK: API Levels:

The codes :

import React, {useState, useEffect, useRef} from 'react';
import {Box, Button, ButtonGroup, ButtonText} from '@gluestack-ui/themed';
import SignatureScreen from 'react-native-signature-canvas';
import {Sign} from '../components';

export default function SignPad({navigation, route}) {
  const handleOk = () => {};
  const ref = useRef();
  const [signature, setSign] = useState(null);

  const handleConfirm = () => {
    ref.current.readSignature();
  };

  const handleClear = () => {
    setSign(null);
    ref.current.clearSignature();
  };

  return (
    <Box flex={1}>
      <SignatureScreen
        ref={ref}
        webStyle={`
                .m-signature-pad {
                  flex: 1;
                  box-shadow: none;
                  border-radius: 10px;
                }
                .m-signature-pad--footer {
                  display: none;
                }
                `}
        onOK={setSign}
        imageType={'image/png+xml'}
        // autoClear
      />
      <ButtonGroup>
        <Button onPress={handleConfirm}>
          <ButtonText>Simpan</ButtonText>
        </Button>
        <Button onPress={handleClear}>
          <ButtonText>Hapus</ButtonText>
        </Button>
      </ButtonGroup>
    </Box>
  );
}

Please help. Thank you