Skip to content

Instantly share code, notes, and snippets.

@ValeryC
Last active May 25, 2018 09:43
Show Gist options
  • Save ValeryC/f6c667d2cbd931ded75094fa9388442e to your computer and use it in GitHub Desktop.
Save ValeryC/f6c667d2cbd931ded75094fa9388442e to your computer and use it in GitHub Desktop.
react affichage du nom de l'auteur sur clique. lancer npm start sur terminale
import React, { Component } from 'react';
class App extends Component {
render() {
return (
<div className="App">
<Author name='Click for author name'/>
<ActionLink />
</div>
);
}
}
class Author extends Component {
click() {
alert('Bob');
}
render() {
return(
<button onClick={this.click.bind(this)}>
{this.props.name}
</button>
)
}
}
//function
const ActionLink = () => {
return (
<a href="https://google.co.uk">
Click me
</a>
);
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment