Latest solutions
interactive-comments-section with react
#reactSubmitted about 1 year agoI have a few questions: I couldn't put my modalDelete, I had some difficulty with it, how to do it. readme.md says that the top level comment should be ordered by their scores: how did you do it? I would like to have feedback on how to improve and manage my code, I think this is my weak point? How do you think about the use of hooks (useReducer and userContext) from the start of the project? finally, I want to make it a full stack project using node.js (express.js), if you have any advice for me THANKS
Latest comments
- @vuson1709@Moulaye-dagnon
You can use the hooks for this :
const [WidthScreem, setWidthSreem] = useState(window.innerWidth) useEffect(()=>{ const handleResize = ()=> setWidthSreem(window.innerWidth) window.addEventListener('resize', handleResize) return ()=> window.removeEventListener('resize', handleResize) },[])
A litle explain :
const [WidthScreem, setWidthSreem] = useState(window.innerWidth) Here we used the state hook and initialized it with the screen size After , you can use an Event on the window so that every time the screen size changes we call seTsetWidthSreem() again . Here we can say that useEffect allows you to automatically refresh the page