Skip to content

Commit

Permalink
feat: adding useIsomorphicLayoutEffect hook package
Browse files Browse the repository at this point in the history
  • Loading branch information
bclark-p44 committed Feb 13, 2023
1 parent 15e0974 commit 527f515
Show file tree
Hide file tree
Showing 15 changed files with 207 additions and 23 deletions.
5 changes: 5 additions & 0 deletions .changeset/long-schools-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@project44-manifest/use-isomorphic-layout-effect': minor
---

Adding useIsomorhpicLayoutEffect hook package
2 changes: 0 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,6 @@ module.exports = {
},
rules: {
// Prefer `it` over `test`
'jest/consistent-test-it': 'error',
'jest/require-top-level-describe': 'error',
'jest/valid-describe-callback': 'error',
'jest/valid-expect': 'error',

Expand Down
32 changes: 32 additions & 0 deletions packages/react/hooks/use-isomorphic-layout-effect/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# @project44-manifest/use-controlled-state

## 0.1.1

### Patch Changes

- [#238](https://github.com/project44/manifest/pull/238)
[`f247e35`](https://github.com/project44/manifest/commit/f247e35a3056d714d8a21ed59ece6b418266332d)
Thanks [@bclark-p44](https://github.com/bclark-p44)! - Fixing issue with workspace dependency
format

## 0.1.0

### Minor Changes

- [#213](https://github.com/project44/manifest/pull/213)
[`345def0`](https://github.com/project44/manifest/commit/345def02dc7f66db38fff6a8716422121c1adf92)
Thanks [@bclark-p44](https://github.com/bclark-p44)! - Adding react transition package

### Patch Changes

- Updated dependencies
[[`345def0`](https://github.com/project44/manifest/commit/345def02dc7f66db38fff6a8716422121c1adf92)]:
- @project44-manifest/react-utils@0.2.4

## 0.1.0

### Minor Changes

- [#204](https://github.com/project44/manifest/pull/204)
[`486d294`](https://github.com/project44/manifest/commit/486d29490cd30b3c2a243fe25c7222db66a1dff0)
Thanks [@bclark-p44](https://github.com/bclark-p44)! - Adding useControlledState hook package
18 changes: 18 additions & 0 deletions packages/react/hooks/use-isomorphic-layout-effect/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
MIT License

Copyright (c) 2021 project44, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4 changes: 4 additions & 0 deletions packages/react/hooks/use-isomorphic-layout-effect/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# @project44-react/react-use-isomorphic-layout-effect

This package is part of [Manifest Design System](https://github.com/project44/manifest). Please see
the repo for more details.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
preset: 'jest-preset-manifest',
};
13 changes: 13 additions & 0 deletions packages/react/hooks/use-isomorphic-layout-effect/moon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
type: 'library'
language: 'typescript'

workspace:
inheritedTasks:
rename:
buildPackage: 'build'

tasks:
build:
outputs:
- 'esm'
- 'lib'
55 changes: 55 additions & 0 deletions packages/react/hooks/use-isomorphic-layout-effect/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "@project44-manifest/use-isomorphic-layout-effect",
"version": "0.0.0",
"description": "Manifest Design System react hook for a ssr safe useEffect",
"license": "MIT",
"author": "project44",
"keywords": [
"manifest",
"design",
"system",
"react",
"hooks"
],
"sideEffects": false,
"main": "./lib/index.js",
"module": "./esm/index.js",
"types": "./dts/index.d.ts",
"files": [
"dts/**/*.d.ts",
"esm/**/*.{js,map}",
"lib/**/*.{js,map}",
"src/**/*.{ts,tsx,json}"
],
"repository": {
"type": "git",
"url": "git@github.com:project-44/manifest.git",
"directory": "packages/react/hookes/use-isomorphic-layout-effect"
},
"publishConfig": {
"access": "public"
},
"peerDependencies": {
"react": "^17.0.0 || ^18.0.0",
"react-dom": "^17.0.0 || ^18.0.0"
},
"devDependencies": {
"react": "^18.1.0",
"react-dom": "^18.1.0"
},
"packemon": {
"platform": "browser"
},
"exports": {
"./package.json": "./package.json",
".": {
"types": "./dts/index.d.ts",
"browser": {
"module": "./esm/index.js",
"import": "./esm/index.js",
"default": "./lib/index.js"
},
"default": "./lib/index.js"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './useIsomorphicLayoutEffect';
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import * as React from 'react';

export const useIsomorphicLayoutEffect =
typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { renderHook } from '@testing-library/react';
import { useIsomorphicLayoutEffect } from '../src';

test('should execute callback', () => {
const callback = jest.fn();
const { result } = renderHook(() => void useIsomorphicLayoutEffect(callback));

expect(result.current).toBeUndefined();
expect(callback).toHaveBeenCalled();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../../../tsconfig.options.json",
"compilerOptions": {
"outDir": "dts",
"rootDir": "src"
},
"include": [
"src/**/*"
],
"references": []
}
15 changes: 15 additions & 0 deletions packages/react/hooks/use-isomorphic-layout-effect/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../../../../tsconfig.options.json",
"compilerOptions": {
"outDir": "../../../../.moon/cache/types/packages/react/hooks/use-isomorphic-layout-effect"
},
"include": [
"src/**/*",
"tests/**/*"
],
"references": [
{
"path": "./tsconfig.build.json"
}
]
}
45 changes: 24 additions & 21 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,73 +9,76 @@
"path": "packages/react/components/avatar"
},
{
"path": "packages/react/components/button"
"path": "packages/react/components/breadcrumb"
},
{
"path": "packages/react/components/breadcrumb"
"path": "packages/react/components/button"
},
{
"path": "packages/react/components/css-baseline"
},
{
"path": "packages/system/tokens"
"path": "packages/react/components/icon"
},
{
"path": "packages/react/components/icon"
"path": "packages/react/components/layout"
},
{
"path": "packages/react/icons"
"path": "packages/react/components/link"
},
{
"path": "tools/jest-preset"
"path": "packages/react/components/popover"
},
{
"path": "packages/react/components/layout"
"path": "packages/react/components/provider"
},
{
"path": "packages/react/components/link"
"path": "packages/react/components/tooltip"
},
{
"path": "packages/react/components/popover"
"path": "packages/react/components/transition"
},
{
"path": "packages/react/components/provider"
"path": "packages/react/components/typography"
},
{
"path": "packages/react/core"
},
{
"path": "packages/react/styles"
"path": "packages/react/hooks/use-controlled-state"
},
{
"path": "packages/react/system"
"path": "packages/react/hooks/use-debounced-state"
},
{
"path": "packages/system/theme"
"path": "packages/react/hooks/use-isomorphic-layout-effect"
},
{
"path": "packages/react/components/tooltip"
"path": "packages/react/hooks/use-merged-ref"
},
{
"path": "packages/react/components/transition"
"path": "packages/react/icons"
},
{
"path": "packages/react/types"
"path": "packages/react/styles"
},
{
"path": "packages/react/components/typography"
"path": "packages/react/system"
},
{
"path": "packages/react/hooks/use-controlled-state"
"path": "packages/react/types"
},
{
"path": "packages/react/hooks/use-debounced-state"
"path": "packages/react/utils"
},
{
"path": "packages/react/hooks/use-merged-ref"
"path": "packages/system/theme"
},
{
"path": "packages/react/utils"
"path": "packages/system/tokens"
},
{
"path": "tools/jest-preset"
}
]
}
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3597,6 +3597,18 @@ __metadata:
languageName: unknown
linkType: soft

"@project44-manifest/use-isomorphic-layout-effect@workspace:packages/react/hooks/use-isomorphic-layout-effect":
version: 0.0.0-use.local
resolution: "@project44-manifest/use-isomorphic-layout-effect@workspace:packages/react/hooks/use-isomorphic-layout-effect"
dependencies:
react: ^18.1.0
react-dom: ^18.1.0
peerDependencies:
react: ^17.0.0 || ^18.0.0
react-dom: ^17.0.0 || ^18.0.0
languageName: unknown
linkType: soft

"@project44-manifest/use-merged-ref@^0.1.1, @project44-manifest/use-merged-ref@workspace:packages/react/hooks/use-merged-ref":
version: 0.0.0-use.local
resolution: "@project44-manifest/use-merged-ref@workspace:packages/react/hooks/use-merged-ref"
Expand Down

1 comment on commit 527f515

@vercel
Copy link

@vercel vercel bot commented on 527f515 Feb 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.