Skip to content

Commit

Permalink
build(deps-dev): bump vite from 3.2.8 to 3.2.10 (#30)
Browse files Browse the repository at this point in the history
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 3.2.8 to 3.2.10.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v3.2.10/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v3.2.10/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
dependabot[bot] authored and ling1726 committed May 24, 2024
1 parent 0083285 commit d6c4b14
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 13 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,26 @@ jobs:
run: |
git status --porcelain
git diff-index --quiet HEAD -- || exit 1
compat:
strategy:
matrix:
# rc tag should be react 19 release candidate
react: [18, rc]
env:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
name: Checkout [main]
with:
fetch-depth: 0
- name: Setup node
uses: actions/[email protected]
with:
node-version: 16.x
- run: npm install
- run: npm install react@${{matrix.react}} react-dom@${{matrix.react}} --force
- run: npm run test:ci
env:
REACT_VERSION: ${{matrix.react}}
- run: npm run build
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@
"release-it": "^15.5.1",
"tsup": "^6.5.0",
"typescript": "^4.9.4",
"vitest": "^0.25.6"
"vitest": "^1.6.0"
}
}
6 changes: 4 additions & 2 deletions src/useDisposable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { renderHook } from "@testing-library/react";
import * as React from "react";
import { useDisposable } from "./useDisposable";

const _maybe_it = process.env.REACT_VERSION === "rc" ? it.skip : it;

describe("useDisposable", () => {
describe("in strict mode", () => {
it("should call factory once during mount", () => {
Expand All @@ -23,7 +25,7 @@ describe("useDisposable", () => {
expect(dispose).toHaveBeenCalledTimes(0);
});

it("should call dispose on unmount", () => {
_maybe_it("should call dispose on unmount", () => {
const dispose = vi.fn();
const { unmount } = renderHook(
() => useDisposable(() => ["foo", dispose], []),
Expand All @@ -37,7 +39,7 @@ describe("useDisposable", () => {
expect(dispose).toHaveBeenCalledTimes(1);
});

it("should call dispose and call factory if dependencies update", () => {
_maybe_it("should call dispose and call factory if dependencies update", () => {
const dispose = vi.fn();
const factory = vi.fn().mockReturnValue(["foo", dispose]);
let dep = "foo";
Expand Down
20 changes: 16 additions & 4 deletions src/useIsStrictMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@ import * as React from "react";
/**
* @returns Current react fiber being rendered
*/
export const getCurrentOwner = () =>
// @ts-ignore - using react internals
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner
.current;
export const getCurrentOwner = () => {
try {
// React 19
// @ts-ignore - using react internals
return React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE.A.getOwner();
} catch {}

try {
// React <18
// @ts-ignore - using react internals
return React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
.ReactCurrentOwner.current;
} catch {
console.error("use-disposable: failed to get current fiber, please report this bug to maintainers");
}
};

const REACT_STRICT_MODE_TYPE = /*#__PURE__*/ Symbol.for("react.strict_mode");

Expand Down

0 comments on commit d6c4b14

Please sign in to comment.