@sonardigital/app-version
v1.0.2
Published
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Readme
@sonardigital/app-version
A lightweight React package for managing and displaying application version information throughout your app.
Installation
npm install @sonardigital/app-versionUsage
Basic Setup
Wrap your application with the AppVersionProvider at the root level:
import { AppVersionProvider } from '@sonardigital/app-version';
function App() {
return (
<AppVersionProvider version="1.0.0">
<YourApp />
</AppVersionProvider>
);
}Accessing Version Information
Use the useAppVersionContext hook to access the version anywhere in your component tree:
import { useAppVersionContext } from '@sonardigital/app-version';
function VersionDisplay() {
const { version } = useAppVersionContext();
return <div>App Version: {version}</div>;
}API Reference
AppVersionProvider
Provider component that makes version information available to the component tree.
Props:
version(string, required): The application version stringchildren(ReactNode, required): Child components
useAppVersionContext
Hook to access version information from the context.
Returns:
version(string): The current application version
Throws:
- Error if used outside of
AppVersionProvider
useAppVersion
Low-level hook for managing version state. Typically used internally by the provider.
Props:
version(string, required): The application version string
Returns:
- Object containing the version
Development
# Lint code
npm run lint
# Format code
npm run format
# Run pre-commit checks
npm run precommitLicense
ISC
