-
Notifications
You must be signed in to change notification settings - Fork 114
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
✨ feat(loading-components.tsx): delayed Rendering #82
Conversation
|
ADDED DELAY RENDERING TO THE LOADING COMPONENTS |
|
||
React.useEffect(() => { | ||
setTimeout(() => setDelayed(false), 500); | ||
}, []); |
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.
can we have a setimeout
@@ -3,13 +3,19 @@ import { Loader } from "react-feather"; | |||
import { cn } from "@/lib/utils"; | |||
|
|||
export function ComponentIsLoading({ fullPage }: { fullPage: boolean }) { | |||
const [delayed, setDelayed] = React.useState(true); |
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.
Can use the useToggle here
const [delayed, setDelayed] = React.useState(true); | ||
|
||
React.useEffect(() => { | ||
setTimeout(() => setDelayed(false), 500); |
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.
Can we also move this 500 to a variable to facilitate easy changing
return ( | ||
<div | ||
className={cn("flex justify-center items-center w-full h-full", { | ||
"w-lvw h-lvh": fullPage, | ||
})} | ||
> | ||
<Loader className="animate-spin w-8 h-8 text-primary" /> | ||
{!delayed && <Loader className="animate-spin w-8 h-8 text-primary" />} |
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.
The delayed logic should cover the whole component
return ( | ||
<div | ||
className={cn("flex justify-center items-center w-full h-full", { | ||
"w-lvw h-lvh": fullPage, | ||
})} | ||
> | ||
<Loader className="animate-spin w-8 h-8 text-primary" /> | ||
{!delayed && <Loader className="animate-spin w-8 h-8 text-primary" />} |
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.
And it would also be nice if we could turn on and off the delayed-ness, not sure it is very loading component that will need it, so we should have room for those that wont need it:
a suggestion is that we have a the wait
prop will have default value, This way we can have something like this
<Delayed wait={500}>
<ComponentIsLoading />
</Delayed>
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.
Got it
I created a new component. Then modified the changes according to the requirements |
added Delayed rendering to the loading component
Pull Request type
Please check the type of change your PR introduces:
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this introduce a breaking change?
Other information