icd2k3 / react-scroll-into-view-if-needed

A thin react component wrapper bundled with scroll-into-view-if-needed
https://codesandbox.io/s/3j4qjp7yp
MIT License
34 stars 8 forks source link

got propsType check error when set boundary #14

Closed yunxifd closed 5 years ago

yunxifd commented 5 years ago

my code

 <ScrollIntoViewIfNeeded
                  elementType="tr"
                  options={{
                      behavior: 'smooth',
                      block: 'nearest',
                      scrollMode: 'if-needed',
                      boundary: document.getElementById('preAllocation-select-panel')
                  }}
                  active={active}
                  {...props}/>
          );

got error

webpack-internal:///./node_modules/fbjs/lib/warning.js:33 Warning: Failed prop type: Invalid prop `options.boundary` supplied to `ScrollIntoViewIfNeeded`.
    in ScrollIntoViewIfNeeded (created by CustomRow)
    in CustomRow (created by BodyRow)
    in BodyRow (created by TableRow)
    in TableRow (created by Connect(TableRow))
....

I found source code https://github.com/icd2k3/react-scroll-into-view-if-needed/blob/master/src/index.js#L38

because document.getElementById('preAllocation-select-panel') return Element object witch is not React Element . so got error.

icd2k3 commented 5 years ago

Thanks for fixing this!