-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Typescript Migration: client/modules/IDE/hook and client/modules/IDE/utils
#3787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
clairep94
wants to merge
24
commits into
processing:develop
Choose a base branch
from
clairep94:client_modules_IDE_p1
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
5ee0bef
consoleStyles: update to ts, no verify
clairep94 2c3f3d9
add .svg?byContent and .svg?byUrl to custom types
clairep94 7445aec
consoleStyles: resolve type errors & update to named export
clairep94 2413816
hooks/index: update to ts
clairep94 3dbcf68
hooks/useWhatPage: update to ts, no-verify
clairep94 f6fb4c4
hooks/useWhatPage: update to named export & resolve type errors
clairep94 d6538ca
hooks/useIsMobile: update to ts, no-verify
clairep94 66ddcb7
hooks/useIsMobile: update to named export & resolve type errors
clairep94 164ce98
hooks/custom-hooks: update to ts, no-verify
clairep94 f8ceb97
hooks/custom-hooks: delete unused hooks, resolve type errors
clairep94 b897501
hooks/custom-hooks: update file to useDidUpdate
clairep94 0f40933
IDE/hooks/useInterval: update to ts, no-verify
clairep94 17a18c2
IDE/hooks/useInterval: update to named export and resolve type errors
clairep94 515f2ca
hooks/useIsMobile: add types for react-responsive
clairep94 e22ae36
hooks/useDidUpdate: minor cleanup
clairep94 218ad0f
hooks/useP5Version: update to ts, no-verify
clairep94 3164d15
hooks/useP5Versions: resolve type errors
clairep94 814d9d7
hooks/useSketchActions: update to ts, no-verify
clairep94 3c5a071
hooks/useSketchActions: update to named export, resolve type errors
clairep94 f2e0d88
hooks/useSketchActions: memoise methods
clairep94 ad4cdc0
hooks/useHandleMessageEvent: update to ts, no-verify
clairep94 04e839a
hooks/useHandleMessageEvent: resolve type errors, add Message type fr…
clairep94 7173565
IDE/hooks/useP5Version: correct the context type definition
clairep94 28b9b8c
resolve type errors
clairep94 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| export * from './useSketchActions'; | ||
| export * from './useWhatPage'; | ||
| export * from './useIsMobile'; | ||
| export * from './useDidUpdate'; | ||
| export * from './useInterval'; | ||
| export * from './useHandleMessageEvent'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import React, { useEffect, useRef } from 'react'; | ||
|
|
||
| export const useDidUpdate = ( | ||
| callback: () => void, | ||
| deps: React.DependencyList = [] | ||
| ) => { | ||
| const hasMount = useRef(false); | ||
|
|
||
| useEffect(() => { | ||
| if (hasMount.current) { | ||
| callback(); | ||
| } else { | ||
| hasMount.current = true; | ||
| } | ||
| }, deps); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 9 additions & 5 deletions
14
client/modules/IDE/hooks/useInterval.js → client/modules/IDE/hooks/useInterval.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,30 @@ | ||
| // https://overreacted.io/making-setinterval-declarative-with-react-hooks/ | ||
| import { useState, useEffect, useRef } from 'react'; | ||
|
|
||
| export default function useInterval(callback, delay) { | ||
| const savedCallback = useRef(); | ||
| const [intervalId, setIntervalId] = useState(); | ||
| export function useInterval(callback: () => void, delay: number) { | ||
| const savedCallback = useRef<() => void>(); | ||
| const [intervalId, setIntervalId] = useState< | ||
| ReturnType<typeof setInterval> | ||
| >(); | ||
|
|
||
| // Remember the latest callback. | ||
| useEffect(() => { | ||
| savedCallback.current = callback; | ||
| }, [callback]); | ||
|
|
||
| // Set up the interval. | ||
| // eslint-disable-next-line consistent-return | ||
| useEffect(() => { | ||
| function tick() { | ||
| savedCallback.current(); | ||
| if (savedCallback.current) { | ||
| savedCallback.current(); | ||
| } | ||
| } | ||
| if (delay !== null) { | ||
| const id = setInterval(tick, delay); | ||
| setIntervalId(id); | ||
| return () => clearInterval(id); | ||
| } | ||
| return null; | ||
| }, [delay]); | ||
| return () => clearInterval(intervalId); | ||
| } |
4 changes: 1 addition & 3 deletions
4
client/modules/IDE/hooks/useIsMobile.js → client/modules/IDE/hooks/useIsMobile.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,7 @@ | ||
| import { useMediaQuery } from 'react-responsive'; | ||
|
|
||
| const useIsMobile = (customBreakpoint) => { | ||
| export const useIsMobile = (customBreakpoint?: number): boolean => { | ||
| const breakPoint = customBreakpoint || 770; | ||
| const isMobile = useMediaQuery({ maxWidth: breakPoint }); | ||
| return isMobile; | ||
| }; | ||
|
|
||
| export default useIsMobile; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for catching this!