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

Add RN example app (Multiple Realms) #6136

Merged
merged 34 commits into from
Sep 23, 2023
Merged

Conversation

elle-j
Copy link
Member

@elle-j elle-j commented Sep 18, 2023

What, How & Why?

Adds a Netflix-like React Native example app along with the backend App Services App for users who prefer to set it up via the Realm CLI.

For more information and an overview of the project structure, see the README.

Main Files to Review

  • frontend/app/
  • README.md

This closes #5821

☑️ ToDos

--

@coveralls-official
Copy link

coveralls-official bot commented Sep 18, 2023

Coverage Status

coverage: 0.0% (-85.3%) from 85.329% when pulling c91f225 on lj/example-rn-multiple-realms into 613eb24 on main.

Comment on lines +54 to +66
<FlatList
data={movieSections}
initialNumToRender={6}
keyExtractor={section => section.category}
renderItem={({item: section}) => (
<MovieList
category={section.category}
movies={section.movies}
onItemPress={showMovieInfo}
/>
)}
showsVerticalScrollIndicator={false}
/>
Copy link
Member Author

@elle-j elle-j Sep 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we're rendering nested FlatLists. The outer one is the vertical list with each category, and the inner one (rendered by MovieList) contains the horizontal list of movies for 1 category.

This could ideally by swapped for 1 list component (using SectionList) for performance, but SectionList requires Symbol.unscopables to be available on our Results (at least for TypeScript), which we have yet to implement.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really need to fix the unscopables issue. I think the nested FlatList is fine though. I used similar strategies before.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I've seen before that nested FlatLists may cause all list items (in the inner list) to render, so not only when they appear on the screen. In our case, this makes useMemo() even more important.

Copy link
Member

@kneth kneth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I enjoyed reading the top-level README.md, and it should serve as an example for all our examples.

@elle-j
Copy link
Member Author

elle-j commented Sep 20, 2023

Thanks @kneth 🙂


You can either choose to set up your App via a CLI (this has fewer steps and is much faster since all configurations are already provided in the [backend directory](./backend/)), or via the App Services UI (steps provided below).

#### Via a CLI (recommended)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing. This works wonderfully. We should probably adopt this strategy for all our examples. JS people love the terminal ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I definitely think so too. Was talking to Kenneth about it today. Much better DX, less hassle, and less error prone 👍

Copy link
Contributor

@takameyer takameyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very great looking application! This is such a cool example. Really great work here :)

This is to prevent the following eslint error:

Do not define components during render. React will see a new component type on every render and destroy the entire subtree’s DOM nodes and state (https://reactjs.org/docs/reconciliation.html#elements-of-different-types). Instead, move this component definition out of the parent component “RootNavigator” and pass data as props. If you want to allow component creation in props, set allowAsProps option to true. eslintreact/no-unstable-nested-components: https://stackoverflow.com/questions/75493412/react-native-eslint-disable-next-line-react-no-unstable-nested-components
This is to make it easier for users who set up App Services manually rather than via the Realm CLI.
@elle-j elle-j force-pushed the lj/example-rn-multiple-realms branch from b9d9bd4 to c91f225 Compare September 23, 2023 08:39
@elle-j elle-j merged commit 7514009 into main Sep 23, 2023
20 of 30 checks passed
@elle-j elle-j deleted the lj/example-rn-multiple-realms branch September 23, 2023 09:21
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Example in RN: Split data to multiple Realm
3 participants