@monkvision/common
Advanced tools
Comparing version 4.3.12 to 4.3.13
@@ -24,2 +24,3 @@ "use strict"; | ||
var utils_1 = require("../utils"); | ||
var useIsMounted_1 = require("../hooks/useIsMounted"); | ||
/** | ||
@@ -67,2 +68,3 @@ * Local storage key used within Monk web applications to store the authentication token. | ||
var monkSearchParams = (0, searchParams_1.useMonkSearchParams)({ availableVehicleTypes: availableVehicleTypes }); | ||
var isMounted = (0, useIsMounted_1.useIsMounted)(); | ||
(0, monitoring_1.useAppStateMonitoring)({ authToken: authToken, inspectionId: inspectionId, vehicleType: vehicleType, steeringWheel: steeringWheel }); | ||
@@ -80,7 +82,7 @@ (0, analytics_1.useAppStateAnalytics)({ inspectionId: inspectionId }); | ||
var lang = monkSearchParams.get(searchParams_1.MonkSearchParam.LANGUAGE); | ||
if (lang) { | ||
if (lang && isMounted()) { | ||
onFetchLanguage === null || onFetchLanguage === void 0 ? void 0 : onFetchLanguage(lang); | ||
} | ||
} | ||
if (fetchedToken) { | ||
if (fetchedToken && isMounted()) { | ||
setAuthToken(fetchedToken); | ||
@@ -87,0 +89,0 @@ onFetchAuthToken === null || onFetchAuthToken === void 0 ? void 0 : onFetchAuthToken(); |
{ | ||
"name": "@monkvision/common", | ||
"version": "4.3.12", | ||
"version": "4.3.13", | ||
"license": "BSD-3-Clause-Clear", | ||
@@ -31,6 +31,6 @@ "packageManager": "yarn@3.2.4", | ||
"dependencies": { | ||
"@monkvision/analytics": "4.3.12", | ||
"@monkvision/monitoring": "4.3.12", | ||
"@monkvision/sights": "4.3.12", | ||
"@monkvision/types": "4.3.12", | ||
"@monkvision/analytics": "4.3.13", | ||
"@monkvision/monitoring": "4.3.13", | ||
"@monkvision/sights": "4.3.13", | ||
"@monkvision/types": "4.3.13", | ||
"i18next": "^23.4.5", | ||
@@ -51,9 +51,9 @@ "jsonwebtoken": "^9.0.2", | ||
"devDependencies": { | ||
"@monkvision/eslint-config-base": "4.3.12", | ||
"@monkvision/eslint-config-typescript": "4.3.12", | ||
"@monkvision/eslint-config-typescript-react": "4.3.12", | ||
"@monkvision/jest-config": "4.3.12", | ||
"@monkvision/prettier-config": "4.3.12", | ||
"@monkvision/test-utils": "4.3.12", | ||
"@monkvision/typescript-config": "4.3.12", | ||
"@monkvision/eslint-config-base": "4.3.13", | ||
"@monkvision/eslint-config-typescript": "4.3.13", | ||
"@monkvision/eslint-config-typescript-react": "4.3.13", | ||
"@monkvision/jest-config": "4.3.13", | ||
"@monkvision/prettier-config": "4.3.13", | ||
"@monkvision/test-utils": "4.3.13", | ||
"@monkvision/typescript-config": "4.3.13", | ||
"@testing-library/react": "^12.1.5", | ||
@@ -101,3 +101,3 @@ "@testing-library/react-hooks": "^8.0.1", | ||
"homepage": "https://github.com/monkvision/monkjs", | ||
"gitHead": "1ce5f6ea776ae5bfd394223d81cf50f8681bf6c3" | ||
"gitHead": "01b426413fda27038e5ecbcb74037f2d077a97c6" | ||
} |
@@ -86,2 +86,22 @@ # Hooks | ||
### useIsMounted | ||
```tsx | ||
import { useIsMounted } from '@monkvision/common'; | ||
function TestComponent() { | ||
const [example, setExample] = useState(0); | ||
const isMounted = useIsMounted(); | ||
useEffect(() => { | ||
myAsyncFunc().then((value) => { | ||
if (isMounted()) { | ||
setExample(value); | ||
} | ||
}).catch(console.error); | ||
}, [isMounted]); | ||
} | ||
``` | ||
Custom hook returning a ref to a util function returning `true` if the component using the hook is mounted, and false | ||
otherwise. Can be used to cancel asynchronous calls on component unmounts. | ||
### useForm | ||
@@ -88,0 +108,0 @@ |
248215
147
5266
+ Added@monkvision/analytics@4.3.13(transitive)
+ Added@monkvision/monitoring@4.3.13(transitive)
+ Added@monkvision/sights@4.3.13(transitive)
+ Added@monkvision/types@4.3.13(transitive)
- Removed@monkvision/analytics@4.3.12(transitive)
- Removed@monkvision/monitoring@4.3.12(transitive)
- Removed@monkvision/sights@4.3.12(transitive)
- Removed@monkvision/types@4.3.12(transitive)
Updated@monkvision/analytics@4.3.13
Updated@monkvision/sights@4.3.13
Updated@monkvision/types@4.3.13