SHARE
TWEET

Untitled

a guest Jul 12th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react'
  2.  
  3. class StickyNav extends React.Component {
  4.  
  5.   setLabels (labels) {
  6.     const [ label1, label2 ] = labels
  7.     if (!label1 || !label2) return
  8.     this.label1 = label1.textContent
  9.     this.label2 = label2.textContent
  10.   }
  11.  
  12.   getQuery (query, callback) {
  13.     const el = document.querySelectorAll(query)
  14.     if (!el) return
  15.     if (callback) callback(el)
  16.   }
  17.  
  18.   shouldComponentUpdate (nextProps, nextState) {
  19.     if (this.state.fixed !== nextState.fixed) {
  20.       this.getQuery('#navBar .form-group label', this.setLabels)
  21.       return true
  22.     }
  23.     return false
  24.   }
  25.  
  26.   render () {
  27.     return (
  28.       <div>
  29.         <div className='form-group'>
  30.           <label htmlFor='choice1'><h4>{this.label1}:</h4></label>
  31.           <span id='choice1'> &nbsp;text</span>
  32.         </div>
  33.         <div className='form-group'>
  34.           <label htmlFor='choice2'><h4>{this.label2}:</h4></label>
  35.           <span id='choice2'> &nbsp;text</span>
  36.         </div>
  37.       </div>
  38.     )
  39.   }
  40. }
  41.  
  42. export default StickyNav
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top