react-router-last-location
react-router-last-location copied to clipboard
FaCC, FaPC, Component injection
Possible APIs
Function as Child Component
<div>
<LastLocation>
{(lastLocation) => (
<div>Last location was: {lastLocation.pathname}</div>
)}
</LastLocation>
</div>
Function as Prop Component
const renderLastLocation = (lastLocation) => (
<div>Last location was: {lastLocation.pathname}</div>
);
<div>
<LastLocation renderLastLocation={renderLastLocation} />
</div>
Component injection
const MyComponent = ({ lastLocation }) => (
<div>Last location was: {lastLocation.pathname}</div>
);
<div>
{# Like <Route component={MyComponent} ...> in react-router #}
<LastLocation component={MyComponent} />
</div>
Inspiration
- http://americanexpress.io/faccs-are-an-antipattern/