React native view shot can't receive empty message

489 Views Asked by At

I want to export the image using React Native View Shot, but there is a problem, how come the image doesn't want to export, so there's an error like this. In English, it's like "shot can't receive empty message" enter image description here

this is my code

import ViewShot, { captureScreen } from 'react-native-view-shot';
const viewShotRef = useRef();
const [handleButton, setHandleButton] = useState(true);

async function captureViewShot() {
  setHandleButton(false);
  const imageURI = await viewShotRef.current.capture();
  console.log(imageURI);
  setHandleButton(true);
  Share.share({ title: 'Nota', url: imageURI });
}

function captureScreenShot() {
  captureScreen({
    format: 'jpg',
    quality: 0.8,
  }).then(
    (uri) => {
      console.log(uri);
      Share.share({ title: 'Nota', url: uri });
    },
    (error) => console.log('IMage gagal to', error)
  );
}

and this is my viewshot

<ViewShot
  ref={viewShotRef}
  style={{ flex: 1 }}
  options={{ format: 'jpg', quality: 1.0 }}>
  <Table borderStyle={styles.tableStyle}>
    <Row
      data={tableHead}
      style={styles.head}
      textStyle={styles.text}
      flexArr={[1, 2, 1, 1]}
    />
    <Rows data={tableData} textStyle={styles.text} flexArr={[1, 2, 1, 1]} />
  </Table>
</ViewShot>

in my case I need 2 exports, namely export only the table and export the whole screen but neither of them works

0

There are 0 best solutions below