<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Changing time extent on an arcgis-map component with React 18, React Redux 8, and TypeScript (v5) in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-time-extent-on-an-arcgis-map-component/m-p/1616927#M87190</link>
    <description>&lt;P&gt;Thanks. I now have the following code.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;export function MyMap() {
  const mapRef = useRef&amp;lt;HTMLArcgisMapElement&amp;gt;(null);
  const mapState = useSelector((state: StoreState) =&amp;gt; state.map);
  const { webMapItemID, timeExtent: timeExtent } = mapState;

  useEffect(() =&amp;gt; {
    if (mapRef.current &amp;amp;&amp;amp; timeExtent) {
      mapRef.current.view.timeExtent = timeExtent;
    }
  }, [timeExtent]);

  return (
    &amp;lt;div style={{ width: "100%", height: "100%" }}&amp;gt;
      &amp;lt;ArcgisMap
        id="my-map"
        ref={mapRef}
        itemId={webMapItemID}
        onArcgisViewReadyChange={() =&amp;gt; {
          mapRef.current!.view.timeExtent = timeExtent;
        }}
      &amp;gt;&amp;lt;/ArcgisMap&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}&lt;/LI-CODE&gt;&lt;P&gt;The ready event and time extent are working, but with an unexpected side effect. It appears the that entire map is re-rendered. When the time extent changes the map briefly goes white and then comes back with the correct map. This happens when I set the time extent as shown, or if set as a property.&lt;/P&gt;&lt;P&gt;I do not want the map to fully re-render when changing the time extent. Is this possible with the wrapper? I cannot upgrade to React 19 at this time.&lt;/P&gt;&lt;P&gt;This was not an issue with the (half-broken) web map component nor using the JS SDK to create the map view.&lt;/P&gt;</description>
    <pubDate>Wed, 21 May 2025 13:12:48 GMT</pubDate>
    <dc:creator>RyanTaylor</dc:creator>
    <dc:date>2025-05-21T13:12:48Z</dc:date>
    <item>
      <title>Changing time extent on an arcgis-map component with React 18, React Redux 8, and TypeScript (v5)</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-time-extent-on-an-arcgis-map-component/m-p/1616793#M87184</link>
      <description>&lt;P&gt;I'm developing a single page application with JavaScript Maps SDK (4.32), React (18), React Redux (8), TypeScript (5), and Webpack (5). I save TimeExtent in the Redux store and would like to use it to change the TimeExtent on the arcgis-map component. Here's my code...&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;/// &amp;lt;reference types="@arcgis/map-components/types/react" /&amp;gt;
import React from "react";
import { useSelector } from "react-redux";
import "@arcgis/map-components/components/arcgis-map";

export function MyMap() {
  const mapState = useSelector((state: StoreState) =&amp;gt; state.map);
  const { webMapItemID, timeExtent } = mapState;

  return (
    &amp;lt;arcgis-map 
        item-id={webMapItemID}
        timeExtent={timeExtent}&amp;gt;
        onarcgisViewReadyChange={(event) =&amp;gt; console.log("ready")}
    &amp;lt;/arcgis-map&amp;gt;
  );
}&lt;/LI-CODE&gt;&lt;P&gt;This code does not work. Specifically, the time extent is never set on the map (the time extent is correct, but the map never sets it internally) and the ready change event is never called (nothing is written to the console).&lt;/P&gt;&lt;P&gt;However, I can set the time extent and listen for the ready change event by obtaining a reference to the arcgis-map web component on mount.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;/// &amp;lt;reference types="@arcgis/map-components/types/react" /&amp;gt;
import React, { useEffect } from "react";
import { useSelector } from "react-redux";
import "@arcgis/map-components/components/arcgis-map";

export function MyMap() {
  const mapState = useSelector((state: StoreState) =&amp;gt; state.map);
  const { webMapItemID, timeExtent } = mapState;

  useEffect(() =&amp;gt; {
    const map = document.querySelector("arcgis-map");

    map?.addEventListener("arcgisViewReadyChange", (event) =&amp;gt; {
      map.view.timeExtent = timeExtent;
    });
    
  }, []);

  return &amp;lt;arcgis-map item-id={webMapItemID}&amp;gt;&amp;lt;/arcgis-map&amp;gt;;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I not understanding about the first example? What is the recommended programming pattern when using web components, react 18, and redux?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 May 2025 00:32:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-time-extent-on-an-arcgis-map-component/m-p/1616793#M87184</guid>
      <dc:creator>RyanTaylor</dc:creator>
      <dc:date>2025-05-21T00:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: Changing time extent on an arcgis-map component with React 18, React Redux 8, and TypeScript (v5)</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-time-extent-on-an-arcgis-map-component/m-p/1616802#M87185</link>
      <description>&lt;P&gt;I believe I see the issue. Some of the code completions I see in the IDE are for properties and not attributes. Per &lt;A href="https://developers.arcgis.com/javascript/latest/programming-patterns/#attributes-and-properties" target="_blank"&gt;this documentation&lt;/A&gt; properties can only be set via programmatically via JavaScript. The Map Component page lists which &lt;A href="https://developers.arcgis.com/javascript/latest/references/map-components/arcgis-map/#properties" target="_blank"&gt;properties have corresponding attributes&lt;/A&gt; that can be set in HTML. Time Extent is only a property and must be set via JavaScript.&lt;/P&gt;&lt;P&gt;However, that does not explain why my event doesn't fire. It looks like it should &lt;A href="https://github.com/Esri/jsapi-resources/blob/main/component-samples/map-components/samples/react/src/app.jsx#L8" target="_blank"&gt;per this example&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 21 May 2025 00:52:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-time-extent-on-an-arcgis-map-component/m-p/1616802#M87185</guid>
      <dc:creator>RyanTaylor</dc:creator>
      <dc:date>2025-05-21T00:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: Changing time extent on an arcgis-map component with React 18, React Redux 8, and TypeScript (v5)</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-time-extent-on-an-arcgis-map-component/m-p/1616809#M87186</link>
      <description>&lt;P&gt;If you are using React 18, you need to use the map-components-react wrapper to get proper bindings. React 19+ supports native web components, but not 18.&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.npmjs.com/package/@arcgis/map-components-react" target="_blank"&gt;https://www.npmjs.com/package/@arcgis/map-components-react&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 May 2025 01:21:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-time-extent-on-an-arcgis-map-component/m-p/1616809#M87186</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2025-05-21T01:21:11Z</dc:date>
    </item>
    <item>
      <title>Re: Changing time extent on an arcgis-map component with React 18, React Redux 8, and TypeScript (v5)</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-time-extent-on-an-arcgis-map-component/m-p/1616927#M87190</link>
      <description>&lt;P&gt;Thanks. I now have the following code.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;export function MyMap() {
  const mapRef = useRef&amp;lt;HTMLArcgisMapElement&amp;gt;(null);
  const mapState = useSelector((state: StoreState) =&amp;gt; state.map);
  const { webMapItemID, timeExtent: timeExtent } = mapState;

  useEffect(() =&amp;gt; {
    if (mapRef.current &amp;amp;&amp;amp; timeExtent) {
      mapRef.current.view.timeExtent = timeExtent;
    }
  }, [timeExtent]);

  return (
    &amp;lt;div style={{ width: "100%", height: "100%" }}&amp;gt;
      &amp;lt;ArcgisMap
        id="my-map"
        ref={mapRef}
        itemId={webMapItemID}
        onArcgisViewReadyChange={() =&amp;gt; {
          mapRef.current!.view.timeExtent = timeExtent;
        }}
      &amp;gt;&amp;lt;/ArcgisMap&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}&lt;/LI-CODE&gt;&lt;P&gt;The ready event and time extent are working, but with an unexpected side effect. It appears the that entire map is re-rendered. When the time extent changes the map briefly goes white and then comes back with the correct map. This happens when I set the time extent as shown, or if set as a property.&lt;/P&gt;&lt;P&gt;I do not want the map to fully re-render when changing the time extent. Is this possible with the wrapper? I cannot upgrade to React 19 at this time.&lt;/P&gt;&lt;P&gt;This was not an issue with the (half-broken) web map component nor using the JS SDK to create the map view.&lt;/P&gt;</description>
      <pubDate>Wed, 21 May 2025 13:12:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-time-extent-on-an-arcgis-map-component/m-p/1616927#M87190</guid>
      <dc:creator>RyanTaylor</dc:creator>
      <dc:date>2025-05-21T13:12:48Z</dc:date>
    </item>
  </channel>
</rss>

