JSON React layouts data loader
Component middleware for JSON React layouts which enables data loading via the React SSR Data Loader library.
Usage
import { init } from 'json-react-layouts-data-loader'
import { DataLoaderResources, DataProvider } from 'react-ssr-data-loader'
interface MyServices {
}
const resources = new DataLoaderResources<MyServices>()
const { middleware, createRegisterableComponentWithData } = init<MyServices>(resources)
const componentRegistrar = new ComponentRegistrar()
.registerMiddleware(middleware)
export const testComponentWithDataRegistration = createRegisterableComponentWithData(
'test-with-data',
{
loadData: props => {},
},
(props, data) => {
if (!data.loaded) {
return <div>Loading...</div>
}
return <TestComponentWithData data={data.result} />
},
)