Skip to content

Instantly share code, notes, and snippets.

@Manoz
Last active August 12, 2018 08:49
Show Gist options
  • Save Manoz/3c95e1b7076bb9a36f85dbdb981e39e0 to your computer and use it in GitHub Desktop.
Save Manoz/3c95e1b7076bb9a36f85dbdb981e39e0 to your computer and use it in GitHub Desktop.
React reusable component
import React from 'react';
class MyComponent extends React.Component {
render() {
const MyLink = props => <a href={props.theurl} target="_blank" > {props.thename}</a>;
return (
<div>
<nav>
<MyLink theurl="http://www.example.com/page1" thename="My link" />
<MyLink theurl="http://www.example.com/page2" thename="Another link" />
<MyLink theurl="http://www.example.com/page3" thename="A better link" />
<MyLink theurl="http://www.example.com/page4" thename="A bad link" />
</nav>
</div>
);
}
}
export default MyComponent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment