# Does anyone know how to reload the screen while the model URLs are changing dynamically in react-babylon?

**URL:** <https://forum.babylonjs.com/t/does-anyone-know-how-to-reload-the-screen-while-the-model-urls-are-changing-dynamically-in-react-babylon/33238>\
**Category:** Questions\
**Tags:** scene\
**Created:** [August 22, 2022, 5:31am UTC](https://forum.babylonjs.com/t/does-anyone-know-how-to-reload-the-screen-while-the-model-urls-are-changing-dynamically-in-react-babylon/33238 "2022-08-22T05:31:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chaitanya\_Yanamala](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/chaitanya_yanamala/32/26227_2.png) [@Chaitanya\_Yanamala](https://forum.babylonjs.com/u/Chaitanya_Yanamala)\
**Post date:** [August 22, 2022, 5:31am UTC](https://forum.babylonjs.com/t/does-anyone-know-how-to-reload-the-screen-while-the-model-urls-are-changing-dynamically-in-react-babylon/33238/1 "2022-08-22T05:31:22Z")

</div>

Here is my block of code for model.

```auto
**<Suspense fallback={<box name="fallback" />}>
                <Model
                  rootUrl={`https://raw.githubusercontent.com/chaitanyaGitHub1/Images/main/`}
                  sceneFilename={selected_measurement_Style_url}
                  scaleToDimension={0}
                  // morphTargetManager={ }
                  // scaling={new Vector3(1,1,1)}
                  onCreated={(e) => {
                    onCreatedBlouse(e)
                  }}
                  onModelLoaded={(model) => {
                    onBlouseModelLoaded(model)
                    // setLoadModel1(true);
                  }}
                  name={''}
                ></Model>
**

```

selected\_measurement\_Style\_url is the variable will be changing when user selects a new blouse style. I am getting a overlap issue. The new model is loading on top of previous model For example blouse [Top garment] @brianzinn  
Thank you .

 ![Screenshot from 2022-08-22 10-55-50](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/a/c/ac2afa246f4643a46ee644063ae6b1450054a914.png)

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [August 22, 2022, 4:33pm UTC](https://forum.babylonjs.com/t/does-anyone-know-how-to-reload-the-screen-while-the-model-urls-are-changing-dynamically-in-react-babylon/33238/2 "2022-08-22T16:33:11Z")

</div>

cc @brianzinn 🙂

---

<div class="post-metadata">

**Author:** ![brianzinn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/brianzinn/32/28013_2.png) [@brianzinn](https://forum.babylonjs.com/u/brianzinn)\
**Post date:** [August 22, 2022, 5:32pm UTC](https://forum.babylonjs.com/t/does-anyone-know-how-to-reload-the-screen-while-the-model-urls-are-changing-dynamically-in-react-babylon/33238/3 "2022-08-22T17:32:15Z")

</div>

hi @Chaitanya_Yanamala  
I haven’t seen the `<Model ../>` component used that way before. One way would be to key off the `sceneFilename`. That will force the previous model to be disposed:

```nohighlight
  <Suspense ..>
    <Model
      key={selected_measurement_Style_url}
      sceneFilename={selected_measurement_Style_url}
      ...
    </Model>
  </Suspense>

```

Another perhaps more intuitive approach is to move those into the `useEffect` dependency array in the `<Model ../>` component, which matches the `<Suspense ..>...` cache.

> <https://github.com/brianzinn/react-babylonjs/blob/master/packages/react-babylonjs/src/customComponents/Model.tsx#L62>

You can see that the `Model` component is a lightweight Functional Component wrapping the `useSceneLoader` hook. I wouldn’t necessarily want to necessarily dispose() the model without at least a minor bump to add those props as dependencies.

---

<div class="post-metadata">

**Author:** ![Chaitanya\_Yanamala](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/chaitanya_yanamala/32/26227_2.png) [@Chaitanya\_Yanamala](https://forum.babylonjs.com/u/Chaitanya_Yanamala)\
**Post date:** [August 23, 2022, 5:14am UTC](https://forum.babylonjs.com/t/does-anyone-know-how-to-reload-the-screen-while-the-model-urls-are-changing-dynamically-in-react-babylon/33238/4 "2022-08-23T05:14:41Z")

</div>

Thank you @brianzinn@Deltakosh for the reply. I will try this way.

---

<div class="post-metadata">

**Author:** ![Chaitanya\_Yanamala](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/chaitanya_yanamala/32/26227_2.png) [@Chaitanya\_Yanamala](https://forum.babylonjs.com/u/Chaitanya_Yanamala)\
**Post date:** [August 26, 2022, 12:25pm UTC](https://forum.babylonjs.com/t/does-anyone-know-how-to-reload-the-screen-while-the-model-urls-are-changing-dynamically-in-react-babylon/33238/5 "2022-08-26T12:25:38Z")

</div>

I did’t get exactly how to do that way Is there any simple line of code to reload the scene when I change the model URL .

```auto
  useEffect(() => {
    if (scene) {
      // scene.dispose();

      scene.getEngine().runRenderLoop(() => {
        if (scene) {
          scene.render();
        }
      });
    }

  }, [selected_measurement_Style_url])

```

Can I do anything like this .

---

<div class="post-metadata">

**Author:** ![brianzinn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/brianzinn/32/28013_2.png) [@brianzinn](https://forum.babylonjs.com/u/brianzinn)\
**Post date:** [August 27, 2022, 12:05am UTC](https://forum.babylonjs.com/t/does-anyone-know-how-to-reload-the-screen-while-the-model-urls-are-changing-dynamically-in-react-babylon/33238/6 "2022-08-27T00:05:34Z")

</div>

You don’t need to reload the scene - just change the file name and it will dispose the old and load the new automatically. I’ll make some time for a code sandbox hopefully on Sunday - there’s another similar question being asked that needs same answer.

There are some recipes that hide the model and reload it if needed by just showing again, but they rely on the useSceneLoader hook and are better for a finite list of models.

---

<div class="post-metadata">

**Author:** ![brianzinn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/brianzinn/32/28013_2.png) [@brianzinn](https://forum.babylonjs.com/u/brianzinn)\
**Post date:** [August 29, 2022, 7:11pm UTC](https://forum.babylonjs.com/t/does-anyone-know-how-to-reload-the-screen-while-the-model-urls-are-changing-dynamically-in-react-babylon/33238/7 "2022-08-29T19:11:05Z")

</div>

have a look here:  
[floral-water-els13w - CodeSandbox](https://codesandbox.io/s/floral-water-els13w?file=/src/MyScene.tsx)

I can be easily convinced that adding key shouldn’t be default behaviour as it’s not intuitive or user-friendly.

---

<div class="post-metadata">

**Author:** ![Chaitanya\_Yanamala](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/chaitanya_yanamala/32/26227_2.png) [@Chaitanya\_Yanamala](https://forum.babylonjs.com/u/Chaitanya_Yanamala)\
**Post date:** [September 8, 2022, 10:11am UTC](https://forum.babylonjs.com/t/does-anyone-know-how-to-reload-the-screen-while-the-model-urls-are-changing-dynamically-in-react-babylon/33238/8 "2022-09-08T10:11:48Z")

</div>

Thank you @brianzinn
