Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataTable: typescript code of CRUD example produces Unexpected token error #7161

Closed
FrancescoScandiffio opened this issue Sep 12, 2024 · 0 comments · May be fixed by leoo1992/GeradorQRCode#95
Assignees
Labels
Component: Documentation Issue or pull request is related to Documentation
Milestone

Comments

@FrancescoScandiffio
Copy link
Contributor

FrancescoScandiffio commented Sep 12, 2024

Describe the bug

The TypeScript code in the CRUD showcase for the DataTable component is raising two Unexpected token errors, preventing the app from rendering. These errors are also present in the Stackblitz demo published in Section dtproducts on primereact.org

The issue is caused by two malformed strings used as the src field for the product images.

Issue 1

const imageBodyTemplate = (rowData: Product) => {
return <img src={https://primefaces.org/cdn/primereact/images/product/\${rowData.image}} alt={rowData.image!} className="shadow-2 border-round" style={{ width: '64px' }} />;
};
const priceBodyTemplate = (rowData: Product) => {
return formatCurrency(rowData.price);
};

The src string at line 864 should be replaced with the following:

{\`https://primefaces.org/cdn/primereact/images/product/\${rowData.image}\`}

Issue 2

The same issue occurs again at line 962.

<Dialog visible={productDialog} style={{ width: '32rem' }} breakpoints={{ '960px': '75vw', '641px': '90vw' }} header="Product Details" modal className="p-fluid" footer={productDialogFooter} onHide={hideDialog}>
{product.image && <img src={https://primefaces.org/cdn/primereact/images/product/\${product.image}} alt={product.image} className="product-image block m-auto pb-3" />}
<div className="field">
<label htmlFor="name" className="font-bold">
Name

The src string at line 962 should be replaced with the following:

{\`https://primefaces.org/cdn/primereact/images/product/\${product.image}\`}

I am going to open a pull request with this small fix.

Reproducer

No response

System Information

*Executed on stackblitz*

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    primereact: latest => 10.8.2 
    react: 18.3.1 => 18.3.1

Steps to reproduce the behavior

  1. Go to the CRUD example of DataTable
  2. Move to the code section
  3. Select typescript
  4. Click to edit in stackblitz

Expected behavior

No response

@FrancescoScandiffio FrancescoScandiffio added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Sep 12, 2024
@melloware melloware added Component: Documentation Issue or pull request is related to Documentation and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Sep 12, 2024
@melloware melloware added this to the 10.8.3 milestone Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Documentation Issue or pull request is related to Documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants