mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
fix: update errors
This commit is contained in:
1 parent
4ff9a2ec7f
commit
c14efe86cc
34 files changed
+217
-280
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { type RefObject, useEffect, useRef } from 'react';
|
||||
import { type RefObject, useEffect, useRef } from "react";
|
||||
|
||||
interface UseIntersectionOptions extends IntersectionObserverInit {
|
||||
disabled: boolean;
|
||||
@@ -7,9 +7,9 @@ interface UseIntersectionOptions extends IntersectionObserverInit {
|
||||
export function useIntersection(
|
||||
callback: () => void,
|
||||
ref: RefObject<HTMLElement>,
|
||||
options?: UseIntersectionOptions,
|
||||
options?: UseIntersectionOptions
|
||||
) {
|
||||
const observer = useRef<IntersectionObserver>();
|
||||
const observer = useRef<IntersectionObserver>(null!);
|
||||
|
||||
useEffect(() => {
|
||||
if (options?.disabled || !ref.current) return;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { DEFAULT_LOCALE, unwrapper } from '@blitzkit/i18n';
|
||||
import { createContext, useContext, type ReactNode } from 'react';
|
||||
import { getStrings } from '../core/i18n/getStrings';
|
||||
import { unwrapper } from "@blitzkit/i18n";
|
||||
import locales from "@blitzkit/i18n/locales.json";
|
||||
import { createContext, useContext, type ReactNode } from "react";
|
||||
import { getStrings } from "../core/i18n/getStrings";
|
||||
|
||||
const LocaleContext = createContext<{
|
||||
locale: string;
|
||||
@@ -14,7 +15,7 @@ interface LocaleProviderProps extends LocaleAcceptorProps {
|
||||
export function LocaleProvider({ locale, children }: LocaleProviderProps) {
|
||||
return (
|
||||
<LocaleContext.Provider
|
||||
value={{ locale: locale ?? DEFAULT_LOCALE, localeRaw: locale }}
|
||||
value={{ locale: locale ?? locales.default, localeRaw: locale }}
|
||||
>
|
||||
{children}
|
||||
</LocaleContext.Provider>
|
||||
@@ -25,7 +26,7 @@ export function useLocale() {
|
||||
const context = useContext(LocaleContext);
|
||||
|
||||
if (!context) {
|
||||
throw new Error('useLocale must be used within a LocaleProvider');
|
||||
throw new Error("useLocale must be used within a LocaleProvider");
|
||||
}
|
||||
|
||||
const strings = getStrings(context.locale);
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { type RefObject, useEffect, useRef, useState } from 'react';
|
||||
import { type RefObject, useEffect, useRef, useState } from "react";
|
||||
|
||||
/**
|
||||
* Thanks GuCier!
|
||||
* Thanks GuCire!
|
||||
*
|
||||
* https://stackoverflow.com/a/65008608/12294756
|
||||
*/
|
||||
export function useOnScreen(ref: RefObject<HTMLElement>) {
|
||||
const [isIntersecting, setIntersecting] = useState(false);
|
||||
const observer = useRef<IntersectionObserver>();
|
||||
const observer = useRef<IntersectionObserver>(null!);
|
||||
|
||||
useEffect(() => {
|
||||
observer.current = new IntersectionObserver(([entry]) =>
|
||||
setIntersecting(entry.isIntersecting),
|
||||
setIntersecting(entry.isIntersecting)
|
||||
);
|
||||
}, [ref]);
|
||||
|
||||
|
||||
Reference in new issue
Block a user