Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ahooks

Package Overview
Dependencies
Maintainers
5
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ahooks - npm Package Compare versions

Comparing version 3.8.3 to 3.8.4

14

es/useTheme/index.js
import { __read } from "tslib";
import { useEffect, useState } from 'react';
import useMemoizedFn from '../useMemoizedFn';
import isBrowser from '../utils/isBrowser';
export var ThemeMode;

@@ -10,7 +11,10 @@ (function (ThemeMode) {

})(ThemeMode || (ThemeMode = {}));
var matchMedia = window.matchMedia('(prefers-color-scheme: dark)');
function useCurrentTheme() {
var matchMedia = isBrowser ? window.matchMedia('(prefers-color-scheme: dark)') : undefined;
var _a = __read(useState(function () {
var init = matchMedia.matches ? ThemeMode.DARK : ThemeMode.LIGHT;
return init;
if (isBrowser) {
return (matchMedia === null || matchMedia === void 0 ? void 0 : matchMedia.matches) ? ThemeMode.DARK : ThemeMode.LIGHT;
} else {
return ThemeMode.LIGHT;
}
}), 2),

@@ -27,5 +31,5 @@ theme = _a[0],

};
matchMedia.addEventListener('change', onThemeChange);
matchMedia === null || matchMedia === void 0 ? void 0 : matchMedia.addEventListener('change', onThemeChange);
return function () {
matchMedia.removeEventListener('change', onThemeChange);
matchMedia === null || matchMedia === void 0 ? void 0 : matchMedia.removeEventListener('change', onThemeChange);
};

@@ -32,0 +36,0 @@ }, []);

@@ -12,2 +12,3 @@ "use strict";

var _useMemoizedFn = _interopRequireDefault(require("../useMemoizedFn"));
var _isBrowser = _interopRequireDefault(require("../utils/isBrowser"));
var ThemeMode;

@@ -19,7 +20,10 @@ (function (ThemeMode) {

})(ThemeMode || (exports.ThemeMode = ThemeMode = {}));
var matchMedia = window.matchMedia('(prefers-color-scheme: dark)');
function useCurrentTheme() {
var matchMedia = _isBrowser["default"] ? window.matchMedia('(prefers-color-scheme: dark)') : undefined;
var _a = (0, _tslib.__read)((0, _react.useState)(function () {
var init = matchMedia.matches ? ThemeMode.DARK : ThemeMode.LIGHT;
return init;
if (_isBrowser["default"]) {
return (matchMedia === null || matchMedia === void 0 ? void 0 : matchMedia.matches) ? ThemeMode.DARK : ThemeMode.LIGHT;
} else {
return ThemeMode.LIGHT;
}
}), 2),

@@ -36,5 +40,5 @@ theme = _a[0],

};
matchMedia.addEventListener('change', onThemeChange);
matchMedia === null || matchMedia === void 0 ? void 0 : matchMedia.addEventListener('change', onThemeChange);
return function () {
matchMedia.removeEventListener('change', onThemeChange);
matchMedia === null || matchMedia === void 0 ? void 0 : matchMedia.removeEventListener('change', onThemeChange);
};

@@ -41,0 +45,0 @@ }, []);

{
"name": "ahooks",
"version": "3.8.3",
"version": "3.8.4",
"description": "react hooks library",

@@ -5,0 +5,0 @@ "keywords": ["ahooks", "umi hooks", "react hooks"],

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc