Using controller with react-signature-canvas library #4218
Answered
by
NikolaStanisavljevic
NikolaStanisavljevic
asked this question in
Show and tell
-
Has anyone tried to use react-signature-canvas with controller. |
Beta Was this translation helpful? Give feedback.
Answered by
NikolaStanisavljevic
Mar 2, 2021
Replies: 2 comments
-
that's interesting! i haven't tried. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I could not come up with some sensible example, because mine is very specific. let signCanvas = useRef<ReactSignatureCanvas | null>(null);
// Function that will format canvas signature into PNG
const formatIntoPng = () => {
if (signCanvas.current) {
const dataURL = signCanvas.current.toDataURL();
return dataURL;
}
};
// Controler usage example that will save on end of drawing as PNG
<Controller
name="some-name"
control={control}
render={({ value, onChange }) => (
<SignatureCanvas
canvasProps={{ width: width, height: 300, className: 'signCanvas' }}
ref={signCanvas}
onEnd={onChange(formatIntoPng)}
/>
)}
defaultValue=""
/> |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
bluebill1049
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I could not come up with some sensible example, because mine is very specific.
Yet it is possible to use it with with controller,and i had no issues about using it.
Here is something that can be used as code example :