Когда я пытаюсь повернуть одну страницу (а не весь документ), никакие страницы не поворачиваются.
В моем примере я пытаюсь повернуть только страницу 2, но обе страницы отображаются без поворота.
import React, { Component } from 'react';
import { Document, Page } from 'react-pdf';
import samplePdf from './sample.pdf';
class PdfViewer extends Component {
render() {
return (
<Document file={samplePdf}>
<Page pageNumber={1} />
<Page pageNumber={2} rotate={90}/>
</Document>
);
}
}
export default PdfViewer;
При проверке кода кажется, что я нашел источник ошибки. См. Пояснение в строке.
Файл: Document.jsx / Метод: renderChildren
...
renderChildren() {
const { children, className, rotate } = this.props;
const { pdf } = this.state;
const { linkService, registerPage, unregisterPage } = this;
const childProps = {
linkService,
registerPage,
unregisterPage,
pdf,
rotate,
};
//
// BUG FIX
//
// At this point childProps.rotate is "undefined" due to it's assigned from <Document> props. When React.cloneElement is called bellow for each page, childProps.rotate is overwriting the rotate prop of the original <Page> so it's allways set to "undefined". My following piece of code seems to fix the issue:
if (typeof(childProps.rotate) === 'undefined'){
delete childProps.rotate;
}
...
Привет @herneli ,
спасибо за этот отчет! Скоро исправлю.
Привет @herneli ,
рада сообщить, что v2.4.2 отсутствует и включает исправление этой проблемы :) Сообщите мне, что вы думаете.
Большое тебе спасибо. Молодец!!!