refactor: Keep hook function convention the same (#2358)

I standardized the definition of the `useEditor hook` by changing it
from an `arrow function` to a `regular function`, in line with other
editor-related hooks.


### Change Type

- [ ] `patch` — Bug fix
- [ ] `minor` — New feature
- [ ] `major` — Breaking change
- [ ] `dependencies` — Changes to package dependencies[^1]
- [ ] `documentation` — Changes to the documentation only[^2]
- [ ] `tests` — Changes to any test code only[^2]
- [x] `internal` — Any other changes that don't affect the published
package[^2]
- [ ] I don't know

[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: will not publish a new version

### Test Plan

1. Add a step-by-step description of how to test your PR here.
2.

- [x] Unit Tests
- [x] End to end tests

### Release Notes

- Add a brief release note for your PR here.
This commit is contained in:
MinhoPark 2023-12-20 18:06:20 +09:00 committed by GitHub
parent f6e7793f49
commit 3ffcd1601d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 15 deletions

View file

@ -2653,7 +2653,7 @@ export { useComputed }
export function useContainer(): HTMLDivElement; export function useContainer(): HTMLDivElement;
// @public (undocumented) // @public (undocumented)
export const useEditor: () => Editor; export function useEditor(): Editor;
// @public (undocumented) // @public (undocumented)
export function useIsCropping(shapeId: TLShapeId): boolean; export function useIsCropping(shapeId: TLShapeId): boolean;

View file

@ -42130,32 +42130,33 @@
"name": "useContainer" "name": "useContainer"
}, },
{ {
"kind": "Variable", "kind": "Function",
"canonicalReference": "@tldraw/editor!useEditor:var", "canonicalReference": "@tldraw/editor!useEditor:function(1)",
"docComment": "/**\n * @public\n */\n", "docComment": "/**\n * @public\n */\n",
"excerptTokens": [ "excerptTokens": [
{ {
"kind": "Content", "kind": "Content",
"text": "useEditor: " "text": "export declare function useEditor(): "
},
{
"kind": "Content",
"text": "() => "
}, },
{ {
"kind": "Reference", "kind": "Reference",
"text": "Editor", "text": "Editor",
"canonicalReference": "@tldraw/editor!Editor:class" "canonicalReference": "@tldraw/editor!Editor:class"
},
{
"kind": "Content",
"text": ";"
} }
], ],
"fileUrlPath": "packages/editor/src/lib/hooks/useEditor.ts", "fileUrlPath": "packages/editor/src/lib/hooks/useEditor.ts",
"isReadonly": true, "returnTypeTokenRange": {
"releaseTag": "Public",
"name": "useEditor",
"variableTypeTokenRange": {
"startIndex": 1, "startIndex": 1,
"endIndex": 3 "endIndex": 2
} },
"releaseTag": "Public",
"overloadIndex": 1,
"parameters": [],
"name": "useEditor"
}, },
{ {
"kind": "Function", "kind": "Function",

View file

@ -4,6 +4,6 @@ import { Editor } from '../editor/Editor'
export const EditorContext = React.createContext({} as Editor) export const EditorContext = React.createContext({} as Editor)
/** @public */ /** @public */
export const useEditor = (): Editor => { export function useEditor(): Editor {
return React.useContext(EditorContext) return React.useContext(EditorContext)
} }