Skip to content
loading...

How do you handle a component update ?

twitter logo github logo ・1 min read  

i'm working on my portfolio using a React cousin Preact. Component lifecycle are the same and i want to update the route that display details about a project when clicking on another project and i'm lost😅.can you please help me?

twitter logo DISCUSS (6)
markdown guide
 

I believe the lifecycle methods are the same for Preact. In general, you should be able to setState and that should update your component.

For routes, maybe the Preact router readme will help? github.com/developit/preact-router

 

If this is specifically about the router portion, are you missing something like this?

developit / preact-router

:earth_americas: URL router for Preact.

preact-router

NPM travis-ci

Connect your Preact components up to that address bar.

preact-router provides a <Router /> component that conditionally renders its children when the URL matches their path. It also automatically wires up <a /> elements to the router.

💁 Note: This is not a preact-compatible version of React Router. preact-router is a simple URL wiring and does no orchestration for you.

If you're looking for more complex solutions like nested routes and view composition, react-router works great with preact as long as you alias in preact-compat. React Router 4 even works directly with Preact, no compatibility layer needed!

See a Real-world Example ➡️


Usage Example

import Router from 'preact-router'
import { h, render } from 'preact'
/** @jsx h */
const Main = () => (
    <Router>
        <Home path="/" />
        <About
 

I'd already check and use or.the problem is n'ont coming from the router.
Route work well.please if you Can check this and try to it something in ##other project## on the right side

 
 

Can you share any code? In order to see what you have.

 

You Can check thé demo here: for example
By trying to click another projects on the side.
I'll show some codes when i'll bé on my PC

Classic DEV Post from Nov 23 '19

Who are your favorite writers here on DEV?

Who are some people whose posts on DEV you particularly enjoy?

Kael_ profile image
Self-taught UI/UX Designer and Frontend developer. PWA evangelist. Currently learn React/Redux. Would be glad to help you with Designs or Frontend Developement. Don't be afraid to DM