-
-
Notifications
You must be signed in to change notification settings - Fork 457
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f704606
commit 3bfcdb4
Showing
5 changed files
with
102 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,53 @@ | ||
import { WhenVisible } from '@inertiajs/react' | ||
import { useState } from 'react' | ||
|
||
const Foo = ({ label }) => { | ||
return <div>{label}</div> | ||
} | ||
|
||
export default () => ( | ||
<> | ||
<div style={{ marginTop: '5000px' }}> | ||
<WhenVisible data="foo" fallback={<div>Loading first one...</div>}> | ||
<Foo label="First one is visible!" /> | ||
</WhenVisible> | ||
</div> | ||
export default () => { | ||
const [count, setCount] = useState(0) | ||
|
||
<div style={{ marginTop: '5000px' }}> | ||
<WhenVisible buffer={1000} data="foo" fallback={<div>Loading second one...</div>}> | ||
<Foo label="Second one is visible!" /> | ||
</WhenVisible> | ||
</div> | ||
return ( | ||
<> | ||
<div style={{ marginTop: '5000px' }}> | ||
<WhenVisible data="foo" fallback={<div>Loading first one...</div>}> | ||
<Foo label="First one is visible!" /> | ||
</WhenVisible> | ||
</div> | ||
|
||
<div style={{ marginTop: '5000px' }}> | ||
<WhenVisible data="foo" fallback={<div>Loading third one...</div>} always> | ||
<Foo label="Third one is visible!" /> | ||
</WhenVisible> | ||
</div> | ||
<div style={{ marginTop: '5000px' }}> | ||
<WhenVisible buffer={1000} data="foo" fallback={<div>Loading second one...</div>}> | ||
<Foo label="Second one is visible!" /> | ||
</WhenVisible> | ||
</div> | ||
|
||
<div style={{ marginTop: '5000px' }}> | ||
<WhenVisible data="foo" fallback={<div>Loading fourth one...</div>}></WhenVisible> | ||
</div> | ||
</> | ||
) | ||
<div style={{ marginTop: '5000px' }}> | ||
<WhenVisible data="foo" fallback={<div>Loading third one...</div>} always> | ||
<Foo label="Third one is visible!" /> | ||
</WhenVisible> | ||
</div> | ||
|
||
<div style={{ marginTop: '5000px' }}> | ||
<WhenVisible data="foo" fallback={<div>Loading fourth one...</div>}></WhenVisible> | ||
</div> | ||
|
||
<div style={{ marginTop: '6000px' }}> | ||
<WhenVisible | ||
fallback={<div>Loading fifth one...</div>} | ||
always | ||
params={{ | ||
data: { | ||
count, | ||
}, | ||
onSuccess: () => { | ||
setCount((c) => c + 1) | ||
}, | ||
}} | ||
> | ||
<Foo label={`Count is now ${count}`} /> | ||
</WhenVisible> | ||
</div> | ||
</> | ||
) | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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