I'm writing a kibana plugin, and as requirements I should render some visualizations.
Using the code below I can see the visualize rendered correctly.
import { start as embeddables } from "plugins/embeddable_api/np_ready/public/legacy";
...
...
const visParams = {
timeRange: { from: "now-1M", to: "now", mode: "quick" },
filters: [],
query: {},
};
let factory;
if (!factory) {
factory = embeddables.getEmbeddableFactory("visualization");
}
const visHandler = await factory.createFromSavedObject(
visId,
visParams
);
visHandler.render(this.node)
The main problem is after the render method. After it, I can notice a refresh of the webpage that makes me changes the browser url (to the base url of plugin), whitout changing the current view.
I tested this with a dummy plugin and can't reproduce the problem. It's likely related to the rest of your plugin. Could you share it on Github or other means so it's possible to reproduce the issue?
Maybe I found the source problem...
Inside the plugin I used react-router-dom for routing. In the moment I want to render visualizations I open a new view using useHistory with:
import { useHistory } from "react-router-dom";
import chrome from "ui/chrome";
...
let history = useHistory();
history.push(chrome.addBasePath(path));
....
If I apply the url in the browser manually, all is fine, I don't see any refresh.
If I go in that url by code, I see the refresh.
It seems to be a problem related to react-router-dom..
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.