Guest User

Untitled

a guest
May 26th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. class StepOne extends Component {
  2. static getDerivedStateFromProps = (nextProps, prevState) => {
  3. const {
  4. stepOne: { name, location, description }
  5. } = nextProps;
  6. const shouldUpdate = name === prevState.name || prevState.name === '';
  7. return shouldUpdate ? { name } : null;
  8. };
  9.  
  10. state = {
  11. name: '',
  12. location: '',
  13. description: ''
  14. };
  15.  
  16. handleChange = (e) => {
  17. this.setState({ [e.target.name]: e.target.value });
  18. };
  19.  
  20. handleNext = (e) => {
  21. e.preventDefault();
  22. const { name, description, location } = this.state;
  23. this.props.setStepOne({ name, location, description });
  24. };
  25.  
  26. render() {
  27. return (
  28. <Col xs={{ size: 8, offset: 2 }}>
  29. <Col xs='12' className='margin-bottom-60'>
  30. <label className='header-label' htmlFor='name'>
  31. Name
  32. </label>
  33. <input
  34. className='form-input'
  35. placeholder='Whats the conference name?'
  36. id='name'
  37. name='name'
  38. defaultValue={this.props.stepOne.name !== '' ? this.props.stepOne.name : null}
  39. value={this.state.name}
  40. onChange={this.handleChange}
  41. />
  42. </Col>
  43. <Col xs='12' className='margin-bottom-60'>
  44. <label className='header-label' htmlFor='location'>
  45. Location
  46. </label>
  47. <input
  48. className='form-input'
  49. placeholder='Where is the conference located?'
  50. id='location'
  51. name='location'
  52. value={this.state.location}
  53. onChange={this.handleChange}
  54. />
  55. </Col>
  56. <Col xs='12' className='margin-bottom-60'>
  57. <label className='header-label' htmlFor='description'>
  58. Description
  59. </label>
  60. <input
  61. className='form-input'
  62. placeholder='Tell us something more about the conference...'
  63. type='textarea'
  64. id='description'
  65. name='description'
  66. value={this.state.description}
  67. onChange={this.handleChange}
  68. />
  69. </Col>
  70. <div
  71. style={{
  72. width: '100%',
  73. position: 'fixed',
  74. bottom: '0px',
  75. zIndex: '100',
  76. textAlign: 'center',
  77. padding: '10px',
  78. left: '0px'
  79. }}
  80. >
  81. <NextButton handleClick={this.handleNext} />
  82. </div>
  83. </Col>
  84. );
  85. }
  86. }
Add Comment
Please, Sign In to add comment