Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. import React from 'react';
  2. import ReactDOM from 'react-dom';
  3.  
  4. class ShowMore extends React.Component {
  5. state = {
  6. showText: false,
  7. }
  8.  
  9. handleClick = (e) => {
  10. this.setState({
  11. showText: !this.state.showText,
  12. });
  13. }
  14.  
  15. render() {
  16. if(this.state.showText) {
  17. return <div onClick={this.handleClick}>
  18. {this.props.children}
  19. </div>;
  20. }
  21.  
  22. return <a onClick={this.handleClick}>Pokaz więcej</a>
  23. }
  24. }
  25.  
  26. class App extends React.Component {
  27. render() {
  28. return (
  29. <ShowMore>
  30. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin mollis enim eget iaculis fermentum. Nulla facilisi. Morbi auctor quis leo ut efficitur. Duis a nulla sed nunc vestibulum condimentum ac vitae lorem. Vestibulum at ornare lacus, in euismod diam. Fusce varius, justo convallis varius elementum, quam felis molestie purus, accumsan imperdiet lacus nulla sed nunc. Suspendisse efficitur risus vel ante pharetra cursus.</p>
  31. </ShowMore>
  32. )
  33. }
  34. }
  35.  
  36. document.addEventListener('DOMContentLoaded', function () {
  37. ReactDOM.render(
  38. <App />,
  39. document.getElementById('app')
  40. );
  41. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement