Skip to content

Commit

Permalink
Merge pull request #812 from thundersdata-frontend/hooks-issue
Browse files Browse the repository at this point in the history
fix: 修改RN里面判断开发环境的方式
  • Loading branch information
chj-damon authored Jan 8, 2024
2 parents d88b7ff + 603414f commit 8d4b84b
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/khaki-pets-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@td-design/rn-hooks': patch
---

fix: 修改RN里面判断开发环境的方式
2 changes: 1 addition & 1 deletion packages/hooks/src/useDebounceFn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type noop = (...args: any) => any;
* @param options 配置防抖的行为
*/
export default function useDebounceFn<T extends noop>(fn: T, options?: DebounceOptions) {
if (process.env.NODE_ENV !== 'production') {
if (__DEV__) {
if (typeof fn !== 'function') {
throw new Error(`useDebounceFn expected parameter is a function, got ${typeof fn}`);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useMemoizedFn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type noop = (this: any, ...args: any[]) => any;
type PickFunction<T extends noop> = (this: ThisParameterType<T>, ...args: Parameters<T>) => ReturnType<T>;

function useMemoizedFn<T extends noop>(fn: T) {
if (process.env.NODE_ENV !== 'production') {
if (__DEV__) {
if (!isFunction(fn)) {
throw new Error(`useMemoizedFn expected parameter is a function, got ${typeof fn}`);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useMount/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Func = (...args: any[]) => any;
* @param fn mount 时执行的函数
*/
export default function useMount(fn: Func) {
if (process.env.NODE_ENV !== 'production') {
if (__DEV__) {
if (!isFunction(fn)) {
throw new Error(`useMount expected parameter is a function, got ${typeof fn}`);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useRequest/useRequestImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function useRequestImpl<TData, TParams extends any[]>(
) {
const { manual = false, ...rest } = options;

if (process.env.NODE_ENV !== 'production') {
if (__DEV__) {
if (options.defaultParams && !Array.isArray(options.defaultParams)) {
console.warn(`expected defaultParams is array, got ${typeof options.defaultParams}`);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useThrottleFn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type noop = (...args: any) => any;
* @param options 配置节流的行为
*/
export default function useThrottleFn<T extends noop>(fn: T, options?: ThrottleOptions) {
if (process.env.NODE_ENV !== 'production') {
if (__DEV__) {
if (typeof fn !== 'function') {
throw new Error(`useThrottleFn expected parameter is a function, got ${typeof fn}`);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useUnmount/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import useMemoizedFn from '../useMemoizedFn';
type Func = (...args: any[]) => any;

export default function useUnmount(fn: Func) {
if (process.env.NODE_ENV !== 'production') {
if (__DEV__) {
if (typeof fn !== 'function') {
throw new Error(`useUnmount expected parameter is a function, got ${typeof fn}`);
}
Expand Down

0 comments on commit 8d4b84b

Please sign in to comment.