You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ref: widgetApiRef
Define a reference object to address the Widget API wrapper. Use it to access these methods: value, openDialog, reloadInfo and getInput.
Describe the bug
README is incorrect or there is a bug in the code for WidgetRef
See this section in the readme here - https://github.com/uploadcare/react-widget
ref: widgetApiRef
Define a reference object to address the Widget API wrapper. Use it to access these methods: value, openDialog, reloadInfo and getInput.
value() is the alias for widget.value()
openDialog() is the alias for widget.openDialog()
reloadIngo() is the alias for widget.reloadInfo()
getInput() returns widget's input element instance.
Now try this code:
import React, { useRef } from "react";
import ReactDom from "react-dom";
import { Widget } from "@uploadcare/react-widget";
import "./styles.css";
const Example = () => {
const widgetApi = useRef();
return (
<button
onClick={() => {
const widget = widgetApi.current
widget.value("https://i0.wp.com/www.techjunkie.com/wp-content/uploads/2020/08/How-to-Copy-and-Get-a-Link-to-Any-Online-Image-Embedded-in-a-Website.jpg?resize=660%2C430&ssl=1")
const dialog = widget.openDialog();
);
};
ReactDom.render(, document.querySelector("#app"));
You'll get the error: widget.value is not a function
Expected behavior
widget.value should be a function...
Code / screenshots
Environment
I ran this code by modifying the example here https://codesandbox.io/s/keu2y
The text was updated successfully, but these errors were encountered: