Skip to content

Instantly share code, notes, and snippets.

@bussiere
Created March 17, 2019 11:17
Show Gist options
  • Save bussiere/85cee7851d12ed5fa04e9a503ea56e4f to your computer and use it in GitHub Desktop.
Save bussiere/85cee7851d12ed5fa04e9a503ea56e4f to your computer and use it in GitHub Desktop.
ONlick Problem
import * as React from 'react';
import { any } from 'prop-types';
function handleClick(this:any,name:React.ReactNode) {
console.log('The link was clicked.');
this.props.callbackFromParentSearch(name);
}
export const Suggestions = (props:any) => {
const options = props.results.map((r: { id: React.Key; name: React.ReactNode; }) => (
<a href="#" onClick={handleClick(r.name)}>
<li key={r.id}>
{r.name}
</li>
</a>
))
return <ul>{options}</ul>
}
export default Suggestions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment