Added "use client" to hooks.

This commit is contained in:
Mike Cao 2024-02-02 22:20:13 -08:00
parent 400657d59e
commit 238e6efee2
33 changed files with 40 additions and 10 deletions

View File

@ -30,6 +30,7 @@
"rules": {
"no-console": "error",
"react/display-name": "off",
"react-hooks/exhaustive-deps": "off",
"react/react-in-jsx-scope": "off",
"react/prop-types": "off",
"import/no-anonymous-default-export": "off",

View File

@ -1,3 +1,4 @@
'use client';
import { useState } from 'react';
import { createPortal } from 'react-dom';
import { REPORT_PARAMETERS } from 'lib/constants';

View File

@ -1,3 +1,4 @@
'use client';
import * as reactQuery from '@tanstack/react-query';
import { useApi as nextUseApi } from 'next-basics';
import { getClientAuthToken } from 'lib/client';

View File

@ -1,3 +1,4 @@
'use client';
import { useEffect } from 'react';
import useStore, { setConfig } from 'store/app';
import { useApi } from './useApi';

View File

@ -1,3 +1,4 @@
'use client';
import { UseQueryOptions } from '@tanstack/react-query';
import { useState, Dispatch, SetStateAction } from 'react';
import { useApi } from './useApi';

View File

@ -1,3 +1,4 @@
'use client';
import useStore, { setUser } from 'store/app';
import useApi from './useApi';
import { UseQueryResult } from '@tanstack/react-query';

View File

@ -1,3 +1,4 @@
'use client';
import { produce } from 'immer';
import { useCallback, useEffect, useState } from 'react';
import { useApi } from './useApi';

View File

@ -1,3 +1,4 @@
'use client';
import useApi from './useApi';
import useFilterQuery from './useFilterQuery';
import useCache from 'store/cache';

View File

@ -1,3 +1,4 @@
'use client';
import useStore, { setShareToken } from 'store/app';
import useApi from './useApi';

View File

@ -1,3 +1,4 @@
'use client';
import useApi from './useApi';
export function useTeam(teamId: string) {

View File

@ -1,3 +1,4 @@
'use client';
import useApi from './useApi';
import useFilterQuery from './useFilterQuery';

View File

@ -1,3 +1,4 @@
'use client';
import useApi from './useApi';
import useFilterQuery from './useFilterQuery';

View File

@ -1,3 +1,4 @@
'use client';
import useApi from './useApi';
export function useUser(userId: string, options?: { [key: string]: any }) {

View File

@ -1,3 +1,4 @@
'use client';
import useApi from './useApi';
import useFilterQuery from './useFilterQuery';
import useCache from 'store/cache';

View File

@ -1,3 +1,4 @@
'use client';
import useApi from './useApi';
export function useWebsite(websiteId: string, options?: { [key: string]: any }) {

View File

@ -1,3 +1,4 @@
'use client';
import useApi from './useApi';
import { UseQueryOptions } from '@tanstack/react-query';

View File

@ -1,3 +1,4 @@
'use client';
import useApi from './useApi';
import { UseQueryOptions } from '@tanstack/react-query';

View File

@ -1,3 +1,4 @@
'use client';
import { useApi } from './useApi';
import { useFilterQuery } from './useFilterQuery';
import { useLogin } from './useLogin';

View File

@ -1,3 +1,4 @@
'use client';
import { useState, useEffect } from 'react';
import { httpGet } from 'next-basics';
import enUS from '../../../public/intl/country/en-US.json';

View File

@ -1,3 +1,4 @@
'use client';
import { getMinimumUnit, parseDateRange } from 'lib/date';
import { setItem } from 'next-basics';
import { DATE_RANGE_CONFIG, DEFAULT_DATE_RANGE } from 'lib/constants';

View File

@ -1,3 +1,4 @@
'use client';
import { useEffect } from 'react';
export function useDocumentClick(handler: (event: MouseEvent) => any) {

View File

@ -1,3 +1,4 @@
'use client';
import { useEffect, useCallback, KeyboardEvent } from 'react';
export function useEscapeKey(handler: (event: KeyboardEvent) => void) {

View File

@ -1,3 +1,4 @@
'use client';
import { useMessages } from './useMessages';
import { OPERATORS } from 'lib/constants';

View File

@ -1,3 +1,4 @@
'use client';
import { useCallback, useState } from 'react';
export function useForceUpdate() {

View File

@ -1,3 +1,4 @@
'use client';
import useMessages from './useMessages';
import { BROWSERS } from 'lib/constants';
import useLocale from './useLocale';

View File

@ -1,3 +1,4 @@
'use client';
import { useState, useEffect } from 'react';
import { httpGet } from 'next-basics';
import enUS from '../../../public/intl/language/en-US.json';

View File

@ -1,3 +1,4 @@
'use client';
import { useEffect } from 'react';
import { httpGet, setItem } from 'next-basics';
import { LOCALE_CONFIG } from 'lib/constants';

View File

@ -1,6 +1,6 @@
import { useIntl, FormattedMessage, MessageDescriptor, PrimitiveType } from 'react-intl';
'use client';
import { useIntl, FormattedMessage } from 'react-intl';
import { messages, labels } from 'components/messages';
import { FormatXMLElementFn, Options } from 'intl-messageformat';
export function useMessages(): any {
const intl = useIntl();
@ -12,14 +12,12 @@ export function useMessages(): any {
};
const formatMessage = (
descriptor:
| MessageDescriptor
| {
id: string;
defaultMessage: string;
},
values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>,
opts?: Options,
descriptor: {
id: string;
defaultMessage: string;
},
values?: { [key: string]: string },
opts?: any,
) => {
return descriptor ? intl.formatMessage(descriptor, values, opts) : null;
};

View File

@ -1,3 +1,4 @@
'use client';
import { useMemo } from 'react';
import { usePathname, useRouter, useSearchParams } from 'next/navigation';
import { buildUrl } from 'next-basics';

View File

@ -1,3 +1,4 @@
'use client';
import { useState, useEffect, useRef } from 'react';
export function useSticky({ enabled = true, threshold = 1 }) {

View File

@ -1,3 +1,4 @@
'use client';
import { usePathname } from 'next/navigation';
export function useTeamContext(): {

View File

@ -1,3 +1,4 @@
'use client';
import { useEffect } from 'react';
import useStore, { setTheme } from 'store/app';
import { getItem, setItem } from 'next-basics';

View File

@ -1,3 +1,4 @@
'use client';
import { useState, useCallback } from 'react';
import { getTimezone } from 'lib/date';
import { getItem, setItem } from 'next-basics';