Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. // Вспомогательный элемент - рендерит список опций для выбора
  2. function InvSelectOptions(props) {
  3. let set_of_options = []
  4.  
  5. set_of_options = props.values.map((value, index) => (
  6. <option key={`${value}_${index}`} selected={value == props.value} value={value}>
  7. {value}
  8. </option>
  9. ))
  10.  
  11. return (
  12. <span>
  13. {set_of_options}
  14. </span>
  15. )
  16. }
  17.  
  18. // Рендерит фильтр на форме
  19. class InvFilter extends React.Component {
  20. constructor(props) {
  21. super(props)
  22. this.state = {
  23. value: this.props.value
  24. }
  25. }
  26.  
  27. render() {
  28. console.log({InvFilter_this: this})
  29. return (
  30. <div>
  31. {
  32. this.props.select ? (
  33. <select value={this.state.value}>
  34. <InvSelectOptions values={this.props.values} value={this.state.value} />
  35. </select>
  36. ) : this.props.multiselect ? (
  37. <select multiple values={this.props.values}>
  38. <InvSelectOptions values={this.props.values} value={this.state.value} />
  39. </select>
  40. ) : (
  41. <input type={input_type} value={this.props.value} />
  42. )
  43. }
  44. </div>
  45. )
  46. }
  47. }
  48.  
  49. module.exports = InvFilter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement