Skip to content

Tutorial code from React Integration docs does not compile #1

@thepastaclaw

Description

@thepastaclaw

Summary

The code provided in the React Integration tutorial does not compile when followed as written. Multiple issues span the scaffold command, TypeScript types, and API surface mismatches with @dashevo/evo-sdk@3.0.1.

Steps to Reproduce

Followed the tutorial exactly:

  1. npx create-vite@latest my-dash-app -- --template react-ts
  2. cd my-dash-app && npm install
  3. npm install @dashevo/evo-sdk
  4. Created all files as shown in the tutorial
  5. npm run build

Issues Found

1. Scaffold command does not apply the React template

The tutorial says:

npx create-vite@latest my-dash-app -- --template react-ts

The extra -- before --template causes create-vite (v9.x) to ignore the template flag entirely. The resulting project has no React dependencies — no react, react-dom, @types/react, @vitejs/plugin-react, no JSX config.

Fix: Remove the extra --:

npx create-vite@latest my-dash-app --template react-ts

2. DocumentsQuery uses wrong property names

Tutorial uses:

{ contractId: ..., documentType: "listing", ... }

Actual SDK interface (DocumentsQuery):

{ dataContractId: ..., documentTypeName: "listing", ... }

Affected files: ListingsList.tsx, useDocuments.ts

3. Identity method names are wrong

Tutorial uses:

identity.getId().toString()
identity.getBalance().toString()

Actual SDK Identity class:

  • getId() → should be identity.id (getter property, returns Identifier)
  • getBalance() → should be identity.balance (property, bigint)

Affected file: IdentityViewer.tsx

4. Document.getData() does not exist

Tutorial uses:

const d = doc.getData();

The Document class has no getData() method. Document data is accessed via the properties field:

const d = doc.properties;

Affected file: ListingsList.tsx

5. documents.create() API signature is completely different

Tutorial uses:

sdk.documents.create({
  contractId, documentType, document: { ... },
  identityId, privateKeyWif, signingKeyIndex, nonce
})

Actual DocumentsFacade.create() expects:

{ document: Document, identityKey: IdentityPublicKey, signer: IdentitySigner, settings?: PutSettings }

The tutorial shows a simplified "pass fields and a WIF key" interface that does not exist. The real API requires constructing a Document object, an IdentityPublicKey, and an IdentitySigner.

Affected file: CreateListing.tsx

6. useTokenBalance passes string where Identifier is required

Tutorial uses:

sdk.tokens.identityBalances(identityId, [tokenId])

The identityBalances method expects IdentifierLike parameters, but the Map key is Identifier, not string. The .get(tokenId) call with a plain string won't match an Identifier key.

Affected file: useTokenBalance.ts

7. identities.contractNonce is async but called synchronously

Tutorial uses:

nonce: sdk.identities.contractNonce(IDENTITY_ID, CONTRACT_ID)

contractNonce() returns Promise<bigint | null>, not bigint. It needs to be awaited.

Affected file: CreateListing.tsx

Build Output (with scaffold fix applied)

src/components/CreateListing.tsx(21,13): error TS2353: Object literal may only specify known properties, and 'make' does not exist in type 'Document'.
src/components/IdentityViewer.tsx(25,45): error TS2339: Property 'getId' does not exist on type 'Identity'.
src/components/IdentityViewer.tsx(26,50): error TS2551: Property 'getBalance' does not exist on type 'Identity'. Did you mean 'balance'?
src/components/ListingsList.tsx(7,5): error TS2353: Object literal may only specify known properties, and 'contractId' does not exist in type 'DocumentsQuery'.
src/components/ListingsList.tsx(25,25): error TS2339: Property 'getData' does not exist on type 'Document'.
src/components/ListingsList.tsx(27,17): error TS2322: Type 'Identifier' is not assignable to type 'Key | null | undefined'.
src/hooks/useTokenBalance.ts(7,27): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Identifier'.

Environment

  • Node.js: v25.8.1
  • create-vite: 9.0.3
  • @dashevo/evo-sdk: 3.0.1
  • @dashevo/wasm-sdk: 3.0.1
  • TypeScript: 5.9.3
  • macOS arm64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions