클래스 구성 요소를 함수 구성 요소로 변경하고 렌더링 PDF에서 멈췄습니다. 클래스 구성 요소에서 잘 작동했습니다. Kendo 문서에는 클래스 구성 요소 사용 가이드 만 있습니다.
이 구성 요소는 단순히 HTML을 렌더링하고 사용자에게 PDF를 다운로드 할 수있는 옵션을 제공합니다.
import React, { Fragment } from 'react';
import { firestoreConnect } from 'react-redux-firebase';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { PDFExport } from '@progress/kendo-react-pdf';
import { PdfButton } from 'components/StyledButtons';
import {
Container,
CircularProgress
} from '@material-ui/core';
function ViewProject({ _project, props }) {
const exportBriefing = id => e => {
this[id].save();
};
return (
<Fragment>
{_project && (
<Container maxWidth="md">
<PdfButton onClick={exportBriefing(_project.id)} />
<PDFExport
pageTemplate={DocumentTemplate}
paperSize={'A4'}
margin="1.5cm"
scale={0.7}
fileName={'Project_Brief'}
ref={r => (this[_project.id] = r)}
>
<---HTML content here--->
</PDFExport>
</Container>
)}
{!_project && (
<CircularProgress />
)}
</Fragment>
);
}
const mapStateToProps = ({ firestore: { ordered } }) => ({
_project: ordered.project && ordered.project[0],
});
export default compose(
connect(mapStateToProps),
firestoreConnect(props => [
{ collection: 'projects', storeAs: 'project', doc: props.match.params.id },
])
)(ViewProject);
이것은 내 오류입니다 (hY2MWyk4piTBjhpJDFIc은 문서의 'id'입니다).
제안에 미리 감사드립니다.
useRef
후크 를 사용 하여 ref를 null로 선언 한 다음 값을 가져와야합니다.
const myRef = useRef(null);
그런 다음 참조하려는 구성 요소에 연결합니다.
<Fragment>
{_project && (
<Container maxWidth="md">
<PdfButton onClick={exportBriefing(_project.id)} />
<PDFExport
pageTemplate={DocumentTemplate}
paperSize={'A4'}
margin="1.5cm"
scale={0.7}
fileName={ 'Project_Brief'}
ref={ myRef}
>
관련 정보를 더 얻으려면 이 문서 를 확인하세요 useRef
.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다