react-router-last-location icon indicating copy to clipboard operation
react-router-last-location copied to clipboard

FaCC, FaPC, Component injection

Open hinok opened this issue 7 years ago • 0 comments

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/

hinok avatar Nov 03 '17 16:11 hinok