import React, { Component } from 'react'; import { DeferredContent } from '../../components/deferredcontent/DeferredContent'; import { DataTable } from "../../components/datatable/DataTable"; import { Column } from "../../components/column/Column"; import { Toast } from "../../components/toast/Toast"; import { DeferredContentDoc } from './DeferredContentDoc'; import { AppInlineHeader } from '../../AppInlineHeader'; import ProductService from '../service/ProductService'; export class DeferredContentDemo extends Component { constructor(props) { super(props); this.state = { products: null }; this.productService = new ProductService(); this.onImageLoad = this.onImageLoad.bind(this); this.onDataLoad = this.onDataLoad.bind(this); } onImageLoad() { this.toast.show({ severity: 'success', summary: 'Image Initialized', detail: 'Scroll down to load the datatable' }); } onDataLoad() { this.productService.getProductsSmall().then(data => this.setState({ products: data })); this.toast.show({ severity: 'success', summary: 'Data Initialized', detail: 'Render Completed' }); } render() { return (

DeferredContent

DeferredContent postpones the loading the content that is initially not in the viewport until it becomes visible on scroll.

this.toast = el} />
Scroll down to lazy load an image and the DataTable which initiates a query that is not executed on initial page load to speed up load performance.
e.target.src='https://www.primefaces.org/wp-content/uploads/2020/05/placeholder.png'} alt="Prime"/>
) } }