# Error: Trying to use DamlLedgerContext before initializing

**URL:** <https://forum.canton.network/t/error-trying-to-use-damlledgercontext-before-initializing/2406>\
**Category:** App Development\
**Tags:** daml, react, ledger-api\
**Created:** [April 8, 2021, 4:20pm UTC](https://forum.canton.network/t/error-trying-to-use-damlledgercontext-before-initializing/2406 "2021-04-08T16:20:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![palanisamyc](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@palanisamyc](https://forum.canton.network/u/palanisamyc)\
**Post date:** [April 8, 2021, 4:20pm UTC](https://forum.canton.network/t/error-trying-to-use-damlledgercontext-before-initializing/2406/1 "2021-04-08T16:20:36Z")

</div>

Hi,

We are trying to integrate DAML with React application. While we do that getting the attached error. Does anybody faced the same issue ?

 ![Capture](https://canada1.discourse-cdn.com/flex028/uploads/daml/original/2X/1/16fb31468a2509d70820040e57ca90b102102249.png)

Looking forward some suggestion. Thanks in advance.

Regards,  
Palani

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [April 8, 2021, 4:28pm UTC](https://forum.canton.network/t/error-trying-to-use-damlledgercontext-before-initializing/2406/2 "2021-04-08T16:28:08Z")

</div>

Hi @palanisamyc,  
based on the error, it looks like you didn’t wrap the code that uses the hooks in the `DamlLedger` context provider. You can see an example of how to do that in [`create-daml-app`](https://github.com/digital-asset/daml/blob/c220e0538081e5839b1375cde985bf6a504cd867/templates/create-daml-app/ui/src/components/App.tsx#L19).
