-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
44 lines (36 loc) · 1.36 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { useRef } from 'react'
import Sidebar from './components/Sidebar'
import HelloWorld from './components/HelloWorld'
import ReactStickyToParent from '../lib/ReactStickyToParent'
import reactLogo from './assets/react.svg'
import './App.css'
function App() {
// Define a ref for the parent element and pass it to the ReactStickyToParent component
const container = useRef<HTMLElement>(null);
return (
<div className="page">
<aside ref={container} className="container">
<ReactStickyToParent parent={container}>
<div className="sticky">
<h1>Sticky to parent</h1>
<p><strong>Scroll down to see how it works</strong></p>
<hr/>
<p><strong>Note:</strong> the <code>.container</code> should have full height of the column, component sticks to it and moves <i>"inside"</i> it</p>
<hr/>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
<Sidebar/>
</div>
</ReactStickyToParent>
</aside>
<section className="section">
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
<HelloWorld msg="Build for React" />
</section>
</div>
)
}
export default App