Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance and user experience with React.startTransition 🚀 #783

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"devDependencies": {
"@types/lodash.debounce": "4.0.8",
"@types/prop-types": "15.5.2",
"@types/react": "16.4.7",
"@types/react": "^18.3.3",
"@types/react-native": "0.49.5",
"@types/resize-observer-browser": "0.1.7",
"file-directives": "1.4.6",
Expand Down
30 changes: 18 additions & 12 deletions src/core/RecyclerListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ import ItemAnimator, { BaseItemAnimator } from "./ItemAnimator";
import { DebugHandlers } from "..";
import { ComponentCompat } from "../utils/ComponentCompat";
//#if [REACT-NATIVE]
import ScrollComponent from "../platform/reactnative/scrollcomponent/ScrollComponent";
import ViewRenderer from "../platform/reactnative/viewrenderer/ViewRenderer";
import { DefaultJSItemAnimator as DefaultItemAnimator } from "../platform/reactnative/itemanimators/defaultjsanimator/DefaultJSItemAnimator";
import { Platform, ScrollView } from "react-native";
const IS_WEB = !Platform || Platform.OS === "web";
//import ScrollComponent from "../platform/reactnative/scrollcomponent/ScrollComponent";
//import ViewRenderer from "../platform/reactnative/viewrenderer/ViewRenderer";
//import { DefaultJSItemAnimator as DefaultItemAnimator } from "../platform/reactnative/itemanimators/defaultjsanimator/DefaultJSItemAnimator";
//import { Platform, ScrollView } from "react-native";
//const IS_WEB = !Platform || Platform.OS === "web";
sanjaiyan-dev marked this conversation as resolved.
Show resolved Hide resolved
//#endif

/***
* To use on web, start importing from recyclerlistview/web. To make it even easier specify an alias in you builder of choice.
*/

//#if [WEB]
//import ScrollComponent from "../platform/web/scrollcomponent/ScrollComponent";
//import ViewRenderer from "../platform/web/viewrenderer/ViewRenderer";
//import { DefaultWebItemAnimator as DefaultItemAnimator } from "../platform/web/itemanimators/DefaultWebItemAnimator";
//const IS_WEB = true;
//type ScrollView = unknown;
import ScrollComponent from "../platform/web/scrollcomponent/ScrollComponent";
import ViewRenderer from "../platform/web/viewrenderer/ViewRenderer";
import { DefaultWebItemAnimator as DefaultItemAnimator } from "../platform/web/itemanimators/DefaultWebItemAnimator";
const IS_WEB = true;
type ScrollView = unknown;
//#endif

/***
Expand Down Expand Up @@ -557,13 +557,19 @@ export default class RecyclerListView<P extends RecyclerListViewProps, S extends
}

private _queueStateRefresh(): void {
this.refreshRequestDebouncer(() => {
const refreshStates = () => {
if (this._isMounted) {
this.setState((prevState) => {
return prevState;
});
}
});
};

if (typeof React?.startTransition !== "undefined") {
React.startTransition(refreshStates);
} else {
this.refreshRequestDebouncer(refreshStates);
}
}

private _onSizeChanged = (layout: Dimension): void => {
Expand Down