Skip to content

Commit

Permalink
remove react-use and move useIsomorphicLayoutEffect into hooks (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
dagda1 authored Apr 14, 2022
1 parent 533b739 commit 22996a3
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 165 deletions.
7 changes: 7 additions & 0 deletions .changeset/rare-news-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@cutting/hooks": patch
"@cutting/use-get-parent-size": patch
"@cutting/use-mathjax": patch
---

remove react-use and move useIsomorphicLayoutEffect into hooks
7 changes: 2 additions & 5 deletions packages/hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@
},
"dependencies": {
"@cutting/util": "workspace:*",
"assert-ts": "^0.3.4",
"history": "^5.3.0",
"react-use": "^17.3.2",
"resize-observer-polyfill": "^1.5.1",
"use-debounce": "^7.0.1"
"assert-ts": "^0.3.4"
},
"devDependencies": {
"@cutting/devtools": "workspace:*",
Expand All @@ -44,6 +40,7 @@
"@vanilla-extract/babel-plugin": "1.1.5",
"@vanilla-extract/css": "1.6.8",
"eslint": "8.13.0",
"history": "^5.3.0",
"react": "18.0.0",
"react-dom": "18.0.0",
"react-router": "6.3.0",
Expand Down
1 change: 1 addition & 0 deletions packages/hooks/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { useScrollToTop } from './useScrollToTop/useScrollToTop';
export { useIsMounted } from './useIsMounted/useIsMounted';
export { usePrevious } from './usePrevious/usePrevious';
export { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { useEffect, useLayoutEffect } from 'react';

export const useIsomorphicLayoutEffect = typeof document !== 'undefined' ? useLayoutEffect : useEffect;
2 changes: 0 additions & 2 deletions packages/use-get-parent-size/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
"@cutting/hooks": "workspace:*",
"@cutting/util": "workspace:*",
"assert-ts": "^0.3.4",
"history": "^5.3.0",
"react-use": "^17.3.2",
"resize-observer-polyfill": "^1.5.1",
"use-debounce": "^7.0.1"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import type { Dimensions, UseParentSizeOptions, UseParentSizeResult } from './ty
import type { RefObject } from 'react';
import { useCallback, useMemo, useRef, useState } from 'react';
import ResizeObserver from 'resize-observer-polyfill';
import { useIsomorphicLayoutEffect } from 'react-use';
import { useDebouncedCallback } from 'use-debounce';
import { useIsMounted } from '@cutting/hooks';
import { useIsMounted, useIsomorphicLayoutEffect } from '@cutting/hooks';
import { identity, isNil } from '@cutting/util';
import assert from 'assert-ts';

Expand Down
4 changes: 2 additions & 2 deletions packages/use-mathjax/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
"build": "NODE_ENV=production devtools rollup"
},
"dependencies": {
"@cutting/hooks": "workspace:*",
"@cutting/util": "workspace:*",
"assert-ts": "^0.3.4",
"mathjax": "^3.2.0",
"mathjax3": "3.0.0-beta.4",
"react-use": "^17.3.2"
"mathjax3": "3.0.0-beta.4"
},
"devDependencies": {
"@cutting/devtools": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/use-mathjax/src/hooks/useMathJax/useMathJax.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMemo } from 'react';
import { useMathJaxContext } from '../../provider/Provider/Provider';
import { useIsomorphicLayoutEffect } from 'react-use';
import { useIsomorphicLayoutEffect } from '@cutting/hooks';

export interface UseMathJax {
elements?: HTMLElement | HTMLElement[] | SVGGElement | SVGElement[];
Expand Down
2 changes: 1 addition & 1 deletion packages/use-mathjax/src/provider/Provider/Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { MathJax } from 'mathjax3';
import { TeX } from 'mathjax3/mathjax3/input/tex.js';
import { SVG } from 'mathjax3/mathjax3/output/svg.js';
import { AllPackages } from 'mathjax3/mathjax3/input/tex/AllPackages';
import { useIsomorphicLayoutEffect } from 'react-use';
import { useIsomorphicLayoutEffect } from '@cutting/hooks';

interface MathDoc {
version: string;
Expand Down
Loading

0 comments on commit 22996a3

Please sign in to comment.