react-div-100vh
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -1,6 +0,12 @@ | ||
## 0.4.0 (Aug 9, 2020) | ||
## 0.5.0 (Aug 27, 2020) | ||
- [BREAKING CHANGE] `use100vh` returns `null` in Node (when server-side rendered)(@mvasin) | ||
- test: switch to Jest (@mvasin) | ||
- chore: add eslint (@mvasin) | ||
- chore: add prettier (@mvasin) | ||
- [BREAKING CHANGE] `use100vh` React hook was added. It returns height as a `number` in a browser and `undefined` in Node (when server-side rendered). Minimum React version now is "the one with hooks" - 16.8.0 (@mvasin in [29](https://github.com/mvasin/react-div-100vh/pull/xx)) | ||
- [BREAKING CHANGE] `rvh` units were ditched from `Div100vh` component API, use the `use100vh` hook instead (@mvasin in [29](https://github.com/mvasin/react-div-100vh/pull/xx)) | ||
## 0.4.0 (Aug 22, 2020) | ||
- [BREAKING CHANGE] `use100vh` React hook was added. It returns height as a `number` in a browser and `undefined` in Node (when server-side rendered). Minimum React version now is "the one with hooks" - 16.8.0 (@mvasin) | ||
- [BREAKING CHANGE] `rvh` units were ditched from `Div100vh` component API, use the `use100vh` hook instead (@mvasin) | ||
## 0.3.8 (Dec 13, 2019) | ||
@@ -7,0 +13,0 @@ |
@@ -55,6 +55,7 @@ "use strict"; | ||
var _a = react_1.useState(getRealHeight()), height = _a[0], setHeight = _a[1]; | ||
var setRealHeight = function () { | ||
if (height !== getRealHeight()) | ||
setHeight(getRealHeight()); | ||
}; | ||
function setRealHeight() { | ||
var realHeight = getRealHeight(); | ||
if (height !== realHeight) | ||
setHeight(realHeight); | ||
} | ||
react_1.useEffect(function () { | ||
@@ -61,0 +62,0 @@ window.addEventListener('resize', setRealHeight); |
{ | ||
"name": "react-div-100vh", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "A workaround for the '100vh' issue in mobile browsers", | ||
@@ -9,3 +9,6 @@ "license": "MIT", | ||
"scripts": { | ||
"test": "ts-node tests/ssr.tsx", | ||
"test": "jest", | ||
"lint": "eslint lib", | ||
"prettier:check": "prettier --check .", | ||
"prettier:write": "prettier --write .", | ||
"dev": "parcel --out-dir dist-demo demo/index.html", | ||
@@ -24,6 +27,12 @@ "build:demo": "parcel build --out-dir dist-demo demo/index.html", | ||
"@types/react-dom": "^16.9.8", | ||
"@typescript-eslint/eslint-plugin": "^3.10.1", | ||
"@typescript-eslint/parser": "^3.10.1", | ||
"eslint": "^7.7.0", | ||
"eslint-plugin-react": "^7.20.6", | ||
"jest": "^26.4.2", | ||
"parcel-bundler": "^1.12.4", | ||
"prettier": "^2.0.5", | ||
"prettier": "2.1.1", | ||
"react": "^16.13.1", | ||
"react-dom": "^16.13.1", | ||
"ts-jest": "^26.3.0", | ||
"ts-node": "^8.10.2", | ||
@@ -30,0 +39,0 @@ "typescript": "^4.0" |
@@ -31,3 +31,3 @@ # `Div100vh` React component and `use100vh` React hook | ||
For more advanced use cases (for instance, if you need 50% of the real height, and not 100%), there is a named export `use100vh`. This React hook provides an accurate vertical height in pixels. The return type is a `number` in a browser and `undefined` in Node environment. You may need to check if it's not `undefined` if you're doing SSR, otherwise manipulate the value as you wish and concatenate the result with `px`: | ||
For more advanced use cases (for instance, if you need 50% of the real height, and not 100%), there is a named export `use100vh`. This React hook provides an accurate vertical height in pixels. The return type is a `number` in a browser and `null` in Node environment. You may need to check if it's not `null` if you're doing SSR, otherwise manipulate the value as you wish and concatenate the result with `px`: | ||
@@ -34,0 +34,0 @@ ```jsx |
10980
77
15