Advertisement
d4rky

Untitled

Oct 10th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. Generalnie mam sobie taki kawałek kodu, który z react-bootstrap generuje mi formularz (react-bootstrap mi odpowiada, bo mój wewnętrzny styleguide jest celowo bazowany na bootstrapie i jego komponentach):
  2.  
  3. input_series(keys) {
  4. return keys.map(key => {
  5. return (
  6. <RB.FormGroup key={key} validationState={this.state.error && this.state.error[key] ? 'error' : null}>
  7. <RB.ControlLabel>{this.LABELS[key]}</RB.ControlLabel>
  8. <RB.FormControl type="text" value={this.state[key]} onChange={this.onFormChange.bind(this, key)}/>
  9. {this.state.error && this.state.error[key] ? <RB.HelpBlock>{this.state.error[key]}</RB.HelpBlock> : ''}
  10. </RB.FormGroup>
  11. )
  12. })
  13. },
  14.  
  15. Jak widac jest zrobiony w petelce, bo juz mnie wkurwialo robienie 4x dokladnie-kurwa-tego-samego-tylko-ze-zmienionym-name.
  16.  
  17. Tylko teraz problem mam taki, ze robie drugi formularz i tam juz jest textarea:
  18.  
  19. <RB.FormGroup>
  20. <RB.ControlLabel>Description</RB.ControlLabel>
  21. <RB.FormControl
  22. componentClass="textarea"
  23. value={this.state.description}
  24. onChange={this.onFormChange.bind(this, 'description')}
  25. rows="3"/>
  26. {this.state.error && this.state.error['description'] ? <RB.HelpBlock>{this.state.error['description']}</RB.HelpBlock> : ''}
  27. </RB.FormGroup>
  28.  
  29. I w sumie moje pytanie brzmi: wrapujesz sobie takie rzeczy w prostsze helpery, zostawiasz takie i masz 9000 linii kodu czy calkiem jestem debilem i jest na to jakis prosty sposob?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement