<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Marcel Fahle on Medium]]></title>
        <description><![CDATA[Stories by Marcel Fahle on Medium]]></description>
        <link>https://medium.com/@marcelfahle?source=rss-f2c1775594cb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*7X1orMBXR1HH_CPjM6qVVQ.jpeg</url>
            <title>Stories by Marcel Fahle on Medium</title>
            <link>https://medium.com/@marcelfahle?source=rss-f2c1775594cb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 00:52:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@marcelfahle/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[React Router 4 — onRouteChange Event?]]></title>
            <link>https://medium.com/@marcelfahle/react-router-v4-onroutechange-event-a498fe4ca07f?source=rss-f2c1775594cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/a498fe4ca07f</guid>
            <category><![CDATA[react-router]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Marcel Fahle]]></dc:creator>
            <pubDate>Tue, 25 Oct 2016 12:04:51 GMT</pubDate>
            <atom:updated>2016-10-26T15:40:19.239Z</atom:updated>
            <content:encoded><![CDATA[<p>Even though <a href="https://twitter.com/ryanflorence/status/790734093965066241">React Router Version 3 has just been released</a>, I’ve been already <a href="http://ean.gedankenwerk.com/">fiddling around</a> with <a href="https://github.com/ReactTraining/react-router/tree/v4">Version 4</a>, because I wanted to see what the component-based approach was all about.</p><p>Besides being super weird to me at first, it worked out OK. There was only one thing that took me a while to figure out and this post is more me asking for validation than telling you how this shit is supposed to work, so here it goes:</p><p>For the website of the European Aviation Network I needed to add Anchor Tags within Pages, which in my, usually highly over-engineered world, is done by some kind of onChange event on the router, paired with some smooth scrolling done by <a href="https://github.com/fisshy/react-scroll">react-scroll</a> for example.</p><p>The problem was, I couldn’t find any of those events in React Router 4. But since everything is now a React Component, I figured I’d wrap the <em>Match</em>-<em>Component</em> in something else and just use the React lifecycle methods to do what I want. Again, I’m not sure if that’s the proper way to do things here, but it worked for me. Any Feedback is highly appreciated! :)</p><p><strong>The Router:</strong></p><pre>&lt;Router history={ history }&gt;<br>  &lt;div className={wrapperClass} &gt;</pre><pre>  &lt;Header <br>   toggleMenu={ this.toggleMenu } <br>   closeMenu={ this.closeMenu } <br>   isMenu={ this.state.isMenu } <br>   /&gt;</pre><pre>  &lt;CustomMatch exactly pattern=”/” component={ Home }/&gt;<br>  &lt;CustomMatch pattern=”/benefits” component={ Benefits } /&gt;<br>  &lt;CustomMatch pattern=”/how-it-works” component={HowItWorks} /&gt;<br>  &lt;CustomMatch pattern=”/innovation-and-partnership” component={ Innovation } /&gt;<br>  &lt;CustomMatch exactly pattern=”/newsroom” component={ Newsroom } /&gt;</pre><pre>  &lt;Footer /&gt;</pre><pre>  &lt;/div&gt;<br>&lt;/Router&gt;</pre><p><strong>CustomMatch:</strong></p><pre>class CustomMatch extends React.Component {<br>  render() {<br>    return(<br>      &lt;Match {…this.props} render={(matchProps) =&gt; (<br>        &lt;Page&gt;<br>          &lt;this.props.component {…matchProps}/&gt;<br>        &lt;/Page&gt;<br>    )}/&gt;</pre><pre>  )<br> }<br>}</pre><p>Here, I wrap whatever gets rendered in the Match-Component, inside my own Page-Component, where I then just use the regular lifecycle methods to do whatever I want once a Page is rendered, scrolling in this case:</p><pre>componentDidMount() {<br> this.scrollToTarget();<br>}</pre><pre>componentDidUpdate() {<br> this.scrollToTarget();<br>}</pre><p>So, as said, as much as I like that it is working the way I want, I feel like I’m missing something here. Maybe someone out there in the World Wide Interwebz has a better solution for me. Thank you! :-)</p><p>Oh, and Hi, <a href="https://medium.com/u/504c7870fdb6">Medium</a>.</p><p><strong>I’m Marcel and I don’t usually write. But I travel, run and code a lot. I usually post shenanigans related to these things on my </strong><a href="http://twitter.com/marcelfahle"><strong>Twitter</strong></a><strong> or </strong><a href="https://www.instagram.com/marcelfahle/"><strong>Instagram</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a498fe4ca07f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>