Created
July 10, 2018 05:24
-
-
Save anta40/ee406f9794e11c70670df88095880ee2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import logo from './logo.svg'; | |
import './App.css'; | |
import { StickyContainer, Sticky } from 'react-sticky'; | |
class App extends React.Component { | |
render() { | |
return ( | |
<StickyContainer> | |
{/* Other elements can be in between `StickyContainer` and `Sticky`, | |
but certain styles can break the positioning logic used. */} | |
<Sticky> | |
{({ | |
style, | |
// the following are also available but unused in this example | |
isSticky, | |
wasSticky, | |
distanceFromTop, | |
distanceFromBottom, | |
calculatedHeight | |
}) => ( | |
<header style={style}> | |
{/* ... */} | |
</header> | |
)} | |
</Sticky> | |
{/* ... */} | |
</StickyContainer> | |
); | |
} | |
}; | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment