Skip to content

Instantly share code, notes, and snippets.

@anta40
Created July 10, 2018 05:24
Show Gist options
  • Save anta40/ee406f9794e11c70670df88095880ee2 to your computer and use it in GitHub Desktop.
Save anta40/ee406f9794e11c70670df88095880ee2 to your computer and use it in GitHub Desktop.
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