A hook that return url param or calculated value from it.
import React from 'react';
import { useUrlParams } from '@vergiss/chooks';
export default () => {
const sourecFrom = useUrlParams('source-from');
return (
<span>
{ sourceFrom }
</span>
)
}
import React from 'react';
import { useUrlParams } from '@vergiss/chooks';
export default () => {
const isFromIndex = useUrlParmas('source-from', sourceFrom => sourceFrom === 'index');
return (
<span>
{ isFromIndex ? 'yes': 'no' }
</span>
)
}
const value = useUrlParams(
paramName: string
)
const calculatedValue = useUrlParams(
paramName: string,
calculator: (value: any) => any
)
Property | Description | Type | Default |
---|---|---|---|
paramName | Necessary | string |
- |
calculator | Optional, a calculator function | function |
- |