Bart
Explore posts from serversTTCTheo's Typesafe Cult
•Created by Bart on 12/6/2024 in #questions
How to add event listeners in React without useEffect
I heard theo say in multiple videos that useEffect should be used only when nececairy. I was wondering if there is a better way to add this event listener without using useEffect.
useEffect(() => {
const handleEscape = (e: KeyboardEvent) => {
if (e.key === "Escape") setIsEditProfileModalOpen(false)
}
window.addEventListener("keydown", handleEscape)
return () => window.removeEventListener("keydown", handleEscape)
}, [])
6 replies
TTCTheo's Typesafe Cult
•Created by Bart on 10/24/2024 in #questions
Is there an word wrap that works on editable contents? (not css)
I have an editable div on my landingpage that sends its textContext to a thermal printer which then prints it. I would like to have the exact line wrapping on my div as the thermal printer has, this means I cant use the css word wrap since that doesnt work with exact character count.
There are a bunch of npm packages that have word wrap in them but all of them seem to be word wrapping a static text instead of a editable text by the user.
Does anyone know if such a package exists or how to make it myself?
2 replies
KPCKevin Powell - Community
•Created by Bart on 8/29/2024 in #front-end
Is there a way to make the text wrap around the picture in this grid layout?
5 replies