Newbie with React.
I have a long code so I split it to different components.
I have the main widget.tsx component and I imported another component PMtoXY to it.
import PMtoXY from "./PMtoXY";
In the widget, I defined the jimuMapView to access the selected map (script below).
In the PMtoXY, I defined a feature layer and want to add it to the map. How do I access the current state of the jimuMapView in the PMtoXY?
import {
JimuMapViewComponent,
JimuMapView,
} from "jimu-arcgis";
=====
interface IState {
jimuMapView: JimuMapView;
----
----
state = {
jimuMapView: null,
-----
----
activeViewChangeHandler = (jmv: JimuMapView) => {
if (jmv) {
this.setState({ jimuMapView: jmv });
}
};
------
-----
render() {
return (
<div className="widget-addLayers jimu-widget p-2">
{this.props.hasOwnProperty("useMapWidgetIds") &&
this.props.useMapWidgetIds &&
this.props.useMapWidgetIds[0] && (
<JimuMapViewComponent
useMapWidgetId={this.props.useMapWidgetIds?.[0]}
onActiveViewChange={this.activeViewChangeHandler}
/>
)}
--------
--------