dburles / route2

🔗 A simple client side router with React support
2 stars 0 forks source link

Calling subscribe function? #1

Open ralphievolt opened 6 years ago

ralphievolt commented 6 years ago

Will I be able to call this function in componentDidMount and how? My test yields nothing

subscribe(({ path, params }) => console.debug('route: ', { path, params }));

dburles commented 6 years ago

It doesn't really make sense to use that function in the component lifecycle methods since your components are mounted (and unmounted) by the router.

ralphievolt commented 6 years ago

The only reason I'd like to use it is to get the value of the url params. Currently to get the values is to encapsulate my components with withRouter the use props.params.

So I was thinking if subscribe can do the job of my need

dburles commented 6 years ago

Yeah probably too complicated. If you don't like HoC's you can always turn withRouter into a render props component.