# React: how to use this useAssetManager for TaskType.Texture

**URL:** <https://forum.babylonjs.com/t/react-how-to-use-this-useassetmanager-for-tasktype-texture/26414>\
**Category:** Questions\
**Tags:** react\
**Created:** [January 1, 2022, 9:26pm UTC](https://forum.babylonjs.com/t/react-how-to-use-this-useassetmanager-for-tasktype-texture/26414 "2022-01-01T21:26:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![igorroman777](https://avatars.discourse-cdn.com/v4/letter/i/b4bc9f/32.png) [@igorroman777](https://forum.babylonjs.com/u/igorroman777)\
**Post date:** [January 1, 2022, 9:26pm UTC](https://forum.babylonjs.com/t/react-how-to-use-this-useassetmanager-for-tasktype-texture/26414/1 "2022-01-01T21:26:08Z")

</div>

Hi @brianzinn

i use your rbabylonjs-hook.  
It works. But I want to upload the texture:

```auto
const baseUrl = 'http://localhost:3000';
const textureAssetTasks: Task[] = [
    { name: 'preview2', taskType: TaskType.Texture, url: baseUrl+ "/textures/lightmaps/preview2.jpg", noMipmap: true, invertY: false, samplingMode: 1 }
];
const loadedAssets = useAssetManager(textureAssetTasks);
const assetsManagerTask = loadedAssets.taskNameMap['preview2'] as TextureAssetTask;

assetsManagerTask.onSuccess = function(task) {
                    console.log("task.texture is ok");
                    const currentLightmap = task.texture;
                    if(scene) {
                        const mesh = scene.getMeshByName("Floor");
                        if(mesh && mesh.material) {
                            let pbrMaterial = mesh.material as PBRMaterial;
                            pbrMaterial.lightmapTexture = currentLightmap;
                            pbrMaterial.lightmapTexture.coordinatesIndex = 1;
                            pbrMaterial.useLightmapAsShadowmap = true;
                        }
                    }
                };

assetsManagerTask.onError = function (task, message, exception) {
                    console.log("task.texture is error");
                    console.log(message, exception);
                };

```

And there it did not work.  
Am I doing something wrong?

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [January 1, 2022, 10:16pm UTC](https://forum.babylonjs.com/t/react-how-to-use-this-useassetmanager-for-tasktype-texture/26414/2 "2022-01-01T22:16:35Z")

</div>

Do you have any error messages in the console?

---

<div class="post-metadata">

**Author:** ![igorroman777](https://avatars.discourse-cdn.com/v4/letter/i/b4bc9f/32.png) [@igorroman777](https://forum.babylonjs.com/u/igorroman777)\
**Post date:** [January 1, 2022, 10:20pm UTC](https://forum.babylonjs.com/t/react-how-to-use-this-useassetmanager-for-tasktype-texture/26414/3 "2022-01-01T22:20:25Z")

</div>

ok,  
I have the solution::

```auto
               const assetsManagerTask = loadedAssets.taskNameMap['preview2'] as TextureAssetTask;
        
                const currentLightmap = assetsManagerTask.texture;

```

---

<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:** [January 2, 2022, 3:01pm UTC](https://forum.babylonjs.com/t/react-how-to-use-this-useassetmanager-for-tasktype-texture/26414/4 "2022-01-02T15:01:42Z")

</div>

The `taskNameMap` is a convenience - the order remains unchanged, so you can also:

```auto
const assetsManagerTask = loadedAssets[0] as TextureAssetTask;
const currentLightmap = assetsManagerTask.texture;

```

I think you are using ‘react-babylonjs-loaders’ which is a bit of a failed experiment to share code from a couple of years ago. I think I should just move that code into `babylonjs-hook` itself. I have archived the other repo and will try to remember to move that. Cheers.
