react-version-check
Version:
provide a react component to check your code version. when not latest, forces hard refresh on browser
58 lines (57 loc) • 2.02 kB
TypeScript
import { CSSProperties, FC } from "react";
interface Props {
/**
* the version that will be compared against the version on the server.
* should pass it a value from package.json
* @example
* import { VersionCheck } from 'version-check';
* import packageJson from "../package.json";
*
* export function App() {
* return (
* <>
* <VersionCheck currentVersion={packageJson.version} />
* <div>your website</div>
* </>
* );
* }
* */
currentVersion: string;
/**
* the name of the file on the server that the component will fetch and take the version from.
* should be a name of a .json file under "public" directory, that contains content like:
* {"version":"1.0.0"}
* @default "/meta.json"
*/
serverFilePath?: string;
/**
* list of dependencies that will trigger re-checking of the version. when empty, the checking will only happen on first-render
* @default []
* */
dependencies?: any[];
/**
* when true, the component will print console.log that explain what it does
* @default true */
logs?: boolean;
/**
* when true, render small text in the corner of the screen (version text / error text / loading text)
* @default true
*/
display?: boolean;
/** override the default design with your own custom className */
className?: string;
/** override the default design with your own custom style */
style?: CSSProperties;
/**
* in which side of the screen should be displayed?
* @default "left"
* */
side?: "left" | "right";
}
/**
* sometimes browsers cashes websites, thus presenting old version of the site.
* the VersionCheck component check if your version is the latest,
* and if not, it forces hard refresh on the site, to bring its latest version.
* */
export declare const VersionCheck: FC<Props>;
export {};