# Dfx 0.12.1 - importing createActor - dfx generate - do not import from .dfx when using React

**URL:** <https://forum.dfinity.org/t/dfx-0-12-1-importing-createactor-dfx-generate-do-not-import-from-dfx-when-using-react/16648>\
**Category:** Command Line Tools\
**Tags:** JavaScript, Frontend\
**Created:** [November 17, 2022, 2:38pm UTC](https://forum.dfinity.org/t/dfx-0-12-1-importing-createactor-dfx-generate-do-not-import-from-dfx-when-using-react/16648 "2022-11-17T14:38:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![karim](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/karim/32/4680_2.png) [@karim](https://forum.dfinity.org/u/karim)\
**Post date:** [November 17, 2022, 2:38pm UTC](https://forum.dfinity.org/t/dfx-0-12-1-importing-createactor-dfx-generate-do-not-import-from-dfx-when-using-react/16648/1 "2022-11-17T14:38:00Z")

</div>

Sorry for the bad title. I’ll just go through it step by step:

I just upgraded to dfx 0.12.1 and was using the following lines to make non-anonymous calls from my React frontend but this doesn’t work anymore since `createActor` is deprecated:

```auto
import { AuthClient } from "@dfinity/auth-client";
import { createActor, canisterId } from '../../declarations/my_project';

    const getPrincipal = async () => {
        const authClient = await AuthClient.create();
        const identity = await authClient.getIdentity();
        const myActor = createActor(canisterId, {agentOptions: {identity}});
        const response = await myActor.whoami();
        setUser(response.toText());
    };

```

The `/declarations/my_project_backend/index.js` from where I’m importing `createActor` says that we should not import from .dfx but instead use `dfx generate`, so I did the following:

1. Delete the `declarations` folder from the frontend
2. `dfx canister create -all`
3. `dfx generate`
4. `dfx deploy`

Usually I would just call `dfx deploy` and all would be good but as soon as I run that, it overwrites `/declarations/my_project_backend/index.js` and VisualCode again shows `createActor` as deprecated.

The React app also gives a 403 error for a POST request to the backend canister: `Body: Failed to authenticate request 0x427c252e5babb46736a6d8f729cfbcbfcb59bd4791ddf7c5a54dc80d63cd4147 due to: Invalid delegation: Invalid canister signature: IcCanisterSignature signature could not be verified`

Should I just downgrade dfx? What’s up with the `dfx generate` since it does not seem to be run when using `dfx deploy`? Any idea how to fix this project?

---

<div class="post-metadata">

**Author:** ![anon74414410](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon74414410](https://forum.dfinity.org/u/anon74414410)\
**Post date:** [November 17, 2022, 4:38pm UTC](https://forum.dfinity.org/t/dfx-0-12-1-importing-createactor-dfx-generate-do-not-import-from-dfx-when-using-react/16648/2 "2022-11-17T16:38:16Z")

</div>

Typically speaking, the “signature could not be verified” error comes from using a delegated identity that was mainnet on a local replica.

I don’t see your login flow in the example provided above, but can you verify that you are running a local instance of Internet Identity and have logged in with it?

---

<div class="post-metadata">

**Author:** ![karim](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/karim/32/4680_2.png) [@karim](https://forum.dfinity.org/u/karim)\
**Post date:** [November 17, 2022, 4:50pm UTC](https://forum.dfinity.org/t/dfx-0-12-1-importing-createactor-dfx-generate-do-not-import-from-dfx-when-using-react/16648/3 "2022-11-17T16:50:24Z")

</div>

> [@anon74414410](#):
>
> I don’t see your login flow in the example provided above, but can you verify that you are running a local instance of Internet Identity and have logged in with it?

Yes, I do. I just wasn’t aware that it might be connected to the II because the error arose at the same time as the problem with `createActor()`. This is how I log in to the local II:

```auto
    const requestLoginII = async () => {
        const authClient = await AuthClient.create();
        const resolve = await authClient.login({
            identityProvider: 'http://localhost:8000/?canisterId=rkp4c-7iaaa-aaaaa-aaaca-cai'
            // identityProvider: 'https://identity.ic0.app/'
        });
    };

```

---

<div class="post-metadata">

**Author:** ![anon74414410](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon74414410](https://forum.dfinity.org/u/anon74414410)\
**Post date:** [November 17, 2022, 5:24pm UTC](https://forum.dfinity.org/t/dfx-0-12-1-importing-createactor-dfx-generate-do-not-import-from-dfx-when-using-react/16648/4 "2022-11-17T17:24:24Z")

</div>

Okay, I’ve just updated my auth client demo for dfx 0.12.1 and didn’t reproduce your issue. Take a look at [GitHub - krpeacock/auth-client-demo: Example demo of how to use https://www.npmjs.com/package/@dfinity/auth-client to make authenticated calls to an IC app](https://github.com/krpeacock/auth-client-demo) and hopefully the difference will make sense.

If not, if you can provide me with a minimal repo that reproduces the issue, I’ll look into it!

---

<div class="post-metadata">

**Author:** ![karim](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/karim/32/4680_2.png) [@karim](https://forum.dfinity.org/u/karim)\
**Post date:** [November 17, 2022, 6:40pm UTC](https://forum.dfinity.org/t/dfx-0-12-1-importing-createactor-dfx-generate-do-not-import-from-dfx-when-using-react/16648/5 "2022-11-17T18:40:23Z")

</div>

Thank you Kyle! Idk what happened but now it’s working again without me touching anything. Also the look of the II authentication page has slightly changed. Maybe a caching-thing? Anyway, this is resolved for me now.
