xapu

Untitled

Oct 23rd, 2017
129
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react'
  2. import ReactDOM from 'react-dom'
  3.  
  4. let DemoFunc = props => {
  5. function s (props) {
  6. if (props.mood === ':|') {
  7. console.log('y')
  8. return 'Im |'
  9. }
  10. if (props.mood === ':)') {
  11. return 'Im )'
  12. }
  13. if (props.mood === ':|') {
  14. return 'Im (|)'
  15. }
  16. }
  17.  
  18. return (
  19. <div>
  20. <div> Hello {s(props.mood).bind}</div>
  21. <div> Hello {props.mood}</div>
  22. </div>
  23. )
  24. }
  25.  
  26. class Mood extends React.Component {
  27. constructor (props) {
  28. super(props)
  29. this.state = { mood: ':|' }
  30. }
  31. render () {
  32. return (
  33. <div>
  34. <span
  35. style={{
  36. fontSize: '60',
  37. border: '1px solid #333',
  38. cursor: 'pointer'
  39. }}
  40. onClick={this.changeMood.bind(this)}
  41. >
  42. {this.state.mood}
  43.  
  44. </span>
  45. <DemoFunc mood={this.state.mood} />
  46. <div>To</div>
  47. </div>
  48. )
  49. }
  50. changeMood (elem) {
  51. const moods = [':)', ':|', ':(']
  52. const current = moods.indexOf(elem.target.textContent)
  53. this.setState({ mood: current === 2 ? moods[0] : moods[current + 1] })
  54. }
  55. }
  56.  
  57. ReactDOM.render(<Mood />, root)
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×