futurepress/epubjs-rn

how can get rendition of book at first for highlight some text

Closed this issue ยท 2 comments

i have rendition from onSelected method , but i want get rendition when book open , and highlight some text by cfi

my code:

   onSelected={(cfiRange, rendition) => {
                        console.log("text is selected");
                        this.setState({ selectedCfi: cfiRange });
                        rendition.highlight(cfiRange, {}, (e) => { console.log(e) }, undefined, { 'fill': 'lightblue' });
     
}}

You can do this:

<Epub
    ref={ref => this.epub = ref}
    // other props
/>

then call this.epub.rendition.highlight(...)

thants @SamiChab for answer.