declare var require: any;
import React, { useState } from 'react';
// create empty context as default
const StorageContext = React.createContext({});
export interface IAttachStorage {
addToRenderList: (fRender, hashValue) => void,
isOffline: Boolean | undefined
config: any,
children: any,
preloadedFiles: any,
renderListResults: any
}
const AttachStorage = (props: IAttachStorage) => {
return {props.children}
};
export const serviceWithStorage = (complementedCallback: (listFiles, cbreq, cbres, cbnext) => any) => {
// we return an array of valid middleware-callbacks
return [
async function (req, res, next) {
return await complementedCallback(req.listFiles, req, res, next)
}
]
};
export const serviceAttachStorage = (listFiles) => {
return (req, res, next) => {
req.listFiles = listFiles;
next();
};
}
export function withStorageSsrRendering(Component) {
return function WrapperComponent(props) {
return (
{(context: any) => {
return
}}
);
};
}
export default AttachStorage;