Error when use in react typescript

Stimulsoft Reports.JS discussion
Post Reply
shahink
Posts: 3
Joined: Thu May 16, 2024 8:29 pm

Error when use in react typescript

Post by shahink »

hi
when use stimulsoft with mrt file or mdc file in react js typescript and used sample :

Code: Select all

import  React from 'react';
import { Stimulsoft } from 'stimulsoft-reports-js/Scripts/stimulsoft.viewer';
import 'stimulsoft-reports-js/Css/stimulsoft.viewer.office2013.whiteblue.css';

export default function PrintTest(){
    const viewerOptions=new Stimulsoft.Viewer.StiViewerOptions();
    const viewer = new Stimulsoft.Viewer.StiViewer(viewerOptions, 'StiViewer', false);
    const report = new Stimulsoft.Report.StiReport();

    async function loadPrint(){
        console.log('Loading Viewer view');
        report.loadFile('../../app/reports/rptTest.mrt');
        // const response = await fetch('../../app/reports/ReportTest.mdc');
        // const data = await response.json();
        console.log(report.reportName);
        console.log('Load report from url');
        // report.loadDocument(data);
        viewer.report = report;
        console.log('Rendering the viewer to selected element');
        viewer.renderHtml('invoiceViewer');
    }
    return(
        <>
        <button className="btn btn-blue" onClick={()=>loadPrint()}>show</button>
        <div className="row">
            <div id="invoiceViewer"></div>
        </div>
        </>
    )
}
run the report show error when use mrt file

Code: Select all

Uncaught (in promise) TypeError: i.getCurrentPage() is null
used stimulsoft-reports-js v 2023/01/01
Lech Kulikowski
Posts: 7287
Joined: Tue Mar 20, 2018 5:34 am

Re: Error when use in react typescript

Post by Lech Kulikowski »

Hello,

Please send us a sample project that reproduces the issue for analysis.

Thank you.
shahink
Posts: 3
Joined: Thu May 16, 2024 8:29 pm

Re: Error when use in react typescript

Post by shahink »

Lech Kulikowski wrote: Fri May 17, 2024 9:38 am Hello,

Please send us a sample project that reproduces the issue for analysis.

Thank you.
Hi , this sample attached ,thank you
Attachments
test-report.zip
(198.41 KiB) Downloaded 189 times
shahink
Posts: 3
Joined: Thu May 16, 2024 8:29 pm

Re: Error when use in react typescript

Post by shahink »

hi,guys

I'm resolve this error,There is an important point for addressing the MRT file.
This file must be placed in the public folder of the React project e.g

Code: Select all

report.loadFile('/reports/rptTest.mrt');

my created 'reports' folder in public .

by regards
Lech Kulikowski
Posts: 7287
Joined: Tue Mar 20, 2018 5:34 am

Re: Error when use in react typescript

Post by Lech Kulikowski »

Hello,

Thank you for the information.
Post Reply