Render JSX for custom pagination? #5295
Replies: 3 comments 2 replies
-
take a look at const pagination = {
type: 'custom',
renderCustom: (_, current, total) => {
return return <div> Hello world </div>;
},
} |
Beta Was this translation helpful? Give feedback.
-
I know I am late. and maybe you already solved your problem. but I am putting my solution here so that in the future when someone faces the problem he/she gets the solution. // This ReactDOMServer will help you to return jsx
import * as ReactDOMServer from "react-dom/server";
const pagination = {
clickable: true,
renderBullet: function (index, className) {
return ReactDOMServer.renderToStaticMarkup(<div>This renderToStaticMarkup will convert your JSX into html</div>);
},
}; |
Beta Was this translation helpful? Give feedback.
-
pagination={{
getPageNumbers().forEach((number) => { if (current === number) { text += <li class="swiper-pagination-bullet ${styles.active}">${number}</li> ;} else { text += <li class="swiper-pagination-bullet">${number}</li> ;} }); text += " return text; }, }} |
Beta Was this translation helpful? Give feedback.
-
Hello, I'm trying to render some JSX as custom pagination bullets, but it doesn't work.
Here's my code:
I get an [Object, object] rendered for the pagination.
Beta Was this translation helpful? Give feedback.
All reactions