@datalayer/core
Version:
**Datalayer Core**
29 lines (28 loc) • 849 B
JavaScript
/*
* Copyright (c) 2023-2025 Datalayer, Inc.
* Distributed under the terms of the Modified BSD License.
*/
import { useState } from 'react';
import { useCellStore } from '../state';
import { takeHTMLNodeScreenshot } from '../utils/Screenshot';
const useCellOutputshot = () => {
const [outputshot, setOutputshot] = useState('');
const [error, setError] = useState();
const { update } = useCellStore();
const takeOutputshot = (node) => {
takeHTMLNodeScreenshot(node).then(outputshotData => {
setOutputshot(outputshotData);
update({
outputshotData,
});
return outputshotData;
})
.catch(reason => setError(reason));
};
return [
outputshot,
takeOutputshot,
{ error }
];
};
export default useCellOutputshot;