Skip to content

Commit

Permalink
refactor: remove react namespace import
Browse files Browse the repository at this point in the history
  • Loading branch information
fengkx committed Aug 6, 2021
1 parent 6abe7e4 commit 66a2cb2
Show file tree
Hide file tree
Showing 20 changed files with 15 additions and 23 deletions.
1 change: 0 additions & 1 deletion components/Block/BlockContent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { ShallowBlock } from "@plastic-editor/protocol/lib/protocol";
import { useAtomValue } from "jotai/utils";
import React from "react";
import { EditableBlock } from "../Editor/blocks/Editable";
import { editingBlockIdAtom } from "../Editor/store";
import { Preview } from "./Preview";
Expand Down
4 changes: 2 additions & 2 deletions components/Block/LineDirection.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import { memo as ReactMemo } from "react";
import type { useDrag } from "react-dnd";
type TDragRef = ReturnType<typeof useDrag>[1];
const LineDirectionImpl: React.FC<{ dragRef: TDragRef }> = ({ dragRef }) => {
Expand All @@ -18,5 +18,5 @@ const LineDirectionImpl: React.FC<{ dragRef: TDragRef }> = ({ dragRef }) => {
);
};

export const LineDirection = React.memo(LineDirectionImpl, () => true);
export const LineDirection = ReactMemo(LineDirectionImpl, () => true);
LineDirection.displayName = "LineDirection";
4 changes: 2 additions & 2 deletions components/Block/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import clsx from "clsx";
import deepEqual from "fast-deep-equal/es6/react";
import { useAtomValue, useUpdateAtom } from "jotai/utils";
import { nanoid } from "nanoid";
import React, { useCallback } from "react";
import { memo as ReactMemo, useCallback } from "react";
import { useAdapter } from "../Editor/adapters/AdapterContext";
import { Token, tokenizer } from "../Editor/parser";
import { anchorOffsetAtom, editingBlockIdAtom } from "../Editor/store";
Expand Down Expand Up @@ -62,6 +62,6 @@ const PreviewImpl: React.FC<PropsType> = ({ blockId, className }) => {
);
};

export const Preview = React.memo(PreviewImpl, (prevProps, nextProps) =>
export const Preview = ReactMemo(PreviewImpl, (prevProps, nextProps) =>
deepEqual(prevProps, nextProps)
);
4 changes: 2 additions & 2 deletions components/Block/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import clsx from "clsx";
import deepEqual from "fast-deep-equal/es6/react";
import { useUpdateAtom } from "jotai/utils";
import { nanoid } from "nanoid";
import React, { useRef } from "react";
import { memo as ReactMemo, useRef } from "react";
import { DropTargetMonitor, useDrag, useDrop } from "react-dnd";
import { useAdapter } from "../Editor/adapters/AdapterContext";
import { ID_LEN } from "../Editor/adapters/memory";
Expand Down Expand Up @@ -155,6 +155,6 @@ function BlockChildren({
);
}

export const Block = React.memo(BlockImpl, (prevProps, nextProps) =>
export const Block = ReactMemo(BlockImpl, (prevProps, nextProps) =>
deepEqual(prevProps, nextProps)
);
2 changes: 1 addition & 1 deletion components/Editor/adapters/AdapterContext.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { createContext, useContext } from "react";
import { createContext, useContext } from "react";
import { memoryAdapter } from "./memory";

const AdapterContext = createContext(memoryAdapter);
Expand Down
2 changes: 1 addition & 1 deletion components/Editor/blocks/Bold.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { MouseEventHandler } from "react";
import { MouseEventHandler } from "react";

export type PropType = {
content: string;
Expand Down
2 changes: 1 addition & 1 deletion components/Editor/blocks/Code.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { MouseEventHandler } from "react";
import { MouseEventHandler } from "react";

export type PropType = {
content: string;
Expand Down
2 changes: 1 addition & 1 deletion components/Editor/blocks/Editable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import clsx from "clsx";
import produce from "immer";
import { useAtom } from "jotai";
import { useAtomValue, useUpdateAtom } from "jotai/utils";
import React, { useEffect, useRef } from "react";
import { useEffect, useRef } from "react";
import tinykeys from "tinykeys";
import { useNanoid } from "../../../hooks/useNanoid";
import { useAdapter } from "../adapters/AdapterContext";
Expand Down
1 change: 0 additions & 1 deletion components/Editor/blocks/HyperLink.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Link from "next/link";
import React from "react";

export type PropsType = {
url: string;
Expand Down
1 change: 0 additions & 1 deletion components/Editor/blocks/Image.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
export const Image: React.FC<{ url: string; alt: string }> = ({ url, alt }) => (
// eslint-disable-next-line @next/next/no-img-element
<img src={url} alt={alt} className="max-w-full" />
Expand Down
2 changes: 1 addition & 1 deletion components/Editor/blocks/Todo.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import produce from "immer";
import { useAtom } from "jotai";
import { useAtomValue } from "jotai/utils";
import React, { useCallback } from "react";
import { useCallback } from "react";
import { useAdapter } from "../adapters/AdapterContext";

export const Todo: React.FC<{
Expand Down
1 change: 0 additions & 1 deletion components/Editor/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useMountEffect } from "@react-hookz/web";
import produce from "immer";
import { useRouter } from "next/router";
import React from "react";
import { DndProvider } from "react-dnd";
import { HTML5Backend } from "react-dnd-html5-backend";
import { Block } from "../Block";
Expand Down
1 change: 0 additions & 1 deletion components/Editor/parser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { Text } from "./blocks/Text";
import { rules as builtinRules } from "./rules";
export type Token = {
Expand Down
2 changes: 1 addition & 1 deletion components/LeftAside/ToolButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ImgHTMLAttributes } from "react";
import { ImgHTMLAttributes } from "react";

type ImageAttrsType = ImgHTMLAttributes<HTMLIFrameElement>;
export type PropsType = {
Expand Down
2 changes: 1 addition & 1 deletion components/LeftAside/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useAtom } from "jotai";
import { useAtomValue, useUpdateAtom } from "jotai/utils";
import Link from "next/link";
import { useRouter } from "next/router";
import React, { useCallback } from "react";
import { useCallback } from "react";
import { useAdapter } from "../Editor/adapters/AdapterContext";
import { Note } from "../Editor/adapters/types";
import { ToolButton } from "./ToolButton";
Expand Down
1 change: 0 additions & 1 deletion components/Loading.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import clsx from "clsx";
import React from "react";

type PropsType = {
style?: React.CSSProperties;
Expand Down
2 changes: 1 addition & 1 deletion components/Navbar/PageSearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import produce from "immer";
import { atom, useAtom } from "jotai";
import { useAtomValue, useUpdateAtom } from "jotai/utils";
import Link from "next/link";
import React, { useState } from "react";
import { useState } from "react";
import { useNanoid } from "../../hooks/useNanoid";
import { useAdapter } from "../Editor/adapters/AdapterContext";

Expand Down
1 change: 0 additions & 1 deletion components/Navbar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useAtomValue } from "jotai/utils";
import React from "react";
import { useAdapter } from "../Editor/adapters/AdapterContext";
import { PageSearchInput } from "./PageSearchInput";

Expand Down
2 changes: 1 addition & 1 deletion components/Note.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Block } from "@plastic-editor/protocol/lib/protocol";
import { useAtom } from "jotai";
import { useAtomValue } from "jotai/utils";
import React, { useCallback } from "react";
import { useCallback } from "react";
import { Editor } from "./Editor";
import { useAdapter } from "./Editor/adapters/AdapterContext";
import { Reference } from "./Reference";
Expand Down
1 change: 0 additions & 1 deletion pages/docs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import produce from "immer";
import { useAtom } from "jotai";
import { useUpdateAtom } from "jotai/utils";
import type { NextPage } from "next";
import React from "react";
import {
AdapterProvider,
useAdapter,
Expand Down

1 comment on commit 66a2cb2

@vercel
Copy link

@vercel vercel bot commented on 66a2cb2 Aug 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.