Skip to content

Instantly share code, notes, and snippets.

@vslala
Created July 6, 2019 14:05
Show Gist options
  • Select an option

  • Save vslala/d433c3a62e7023e4e0e4fc9bb5b881c9 to your computer and use it in GitHub Desktop.

Select an option

Save vslala/d433c3a62e7023e4e0e4fc9bb5b881c9 to your computer and use it in GitHub Desktop.
ButtonGroup react component to render buttons
import React from "react";
import "../../actions";
import setTechnology from "../../actions";
import store from '../../store';
export default function ButtonGroup({technologies = []}) {
const dispatchAction = (e) => {
const tech = e.target.dataset.tech;
console.log("Tech: " + tech);
store.dispatch(setTechnology(tech));
}
const buttons = technologies.map( (tech, index) => (
<button
data-tech={tech}
key={index}
onClick={dispatchAction}
>
{tech}
</button>
));
return buttons;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment