git.fiddlerwoaroof.com
src/action-link.js
e49cba82
 
28b358e1
 const ActionLink = (React, PropTypes) => {
e49cba82
 
2aa8beb4
   class ActionLink extends React.Component {
     constructor(props) {
       super(props);
     }
     render() {
       const { action, children, ...props } = this.props;
28b358e1
 
       const renderedRoute = this.store.pathForAction(action);
40d8820d
 
2aa8beb4
       return (
         <a
           href={renderedRoute}
           onClick={ev => {
             ev.preventDefault();
28b358e1
             this.store.dispatch(action);
2aa8beb4
           }}
           {...props}
         >
           {children}
         </a>
       );
     }
478c0afb
   }
 
e49cba82
 
7a0c8d3f
   ActionLink.propTypes = {
2aa8beb4
     action: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
7a0c8d3f
     children: PropTypes.node
   };
384920b4
 
   return ActionLink;
 };
 
 let OutComponent = ActionLink;
 try {
   const React = require("react");
   const PropTypes = require("prop-types");
2aa8beb4
 
28b358e1
   OutComponent = ActionLink(React, PropTypes);
7a0c8d3f
 } catch (e) {
   /* empty */
 }
40d8820d
 
384920b4
 export const _internal = {
   ActionLink
 };
 
 export default OutComponent;