Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions packages/react-meteor-data/.npm/package/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions packages/react-meteor-data/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## v4.0.0-beta.0, xxx
* Breaking change: useFind describes no deps by default [PR#431](https://github.com/meteor/react-packages/pull/431)
* Fix concurrency issue with useFind [PR#419](https://github.com/meteor/react-packages/pull/419)
* Improve `useFind` and `useSubscribe` React suspense hooks [PR#420](https://github.com/meteor/react-packages/pull/429), [PR#430](https://github.com/meteor/react-packages/pull/430) and [PR#441](https://github.com/meteor/react-packages/pull/441)

## v3.0.3, 2024-12-30
* Add `useSubscribeSuspenseServer` hook to be used in SSR.

Expand Down
10 changes: 10 additions & 0 deletions packages/react-meteor-data/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/react-meteor-data/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Package.describe({
name: 'react-meteor-data',
summary: 'React hook for reactively tracking Meteor data',
version: '3.0.6',
version: '4.0.0-beta.1',
documentation: 'README.md',
git: 'https://github.com/meteor/react-packages'
})
Expand All @@ -17,7 +17,7 @@ Package.onUse((api) => {
api.use('tracker')
api.use('ecmascript')
api.use('typescript')
api.use('zodern:[email protected]', 'server')
api.use('zodern:[email protected]')

api.mainModule('index.ts', ['client', 'server'], { lazy: true })
})
Expand Down
35 changes: 17 additions & 18 deletions packages/react-meteor-data/useFind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,23 @@ const fetchData = <T>(cursor: Mongo.Cursor<T>) => {
}

const useSyncEffect = (effect, deps) => {
const [cleanup, timeoutId] = useMemo(
() => {
const cleanup = effect();
const timeoutId = setTimeout(cleanup, 1000);
return [cleanup, timeoutId];
},
deps
);

useEffect(() => {
clearTimeout(timeoutId);

return cleanup;
}, [cleanup]);
};


const useFindClient = <T = any>(factory: () => (Mongo.Cursor<T> | undefined | null), deps: DependencyList = []) => {
const [cleanup, timeoutId] = useMemo(
() => {
const cleanup = effect();
const timeoutId = setTimeout(cleanup, 1000);
return [cleanup, timeoutId];
},
deps
);

useEffect(() => {
clearTimeout(timeoutId);

return cleanup;
}, [cleanup]);
};

const useFindClient = <T = any>(factory: () => (Mongo.Cursor<T> | undefined | null), deps: DependencyList) => {
const cursor = useMemo(() => {
// To avoid creating side effects in render, opt out
// of Tracker integration altogether.
Expand Down