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

Explicitly add children to provider props #4566

Merged
merged 3 commits into from
May 11, 2022
Merged
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
1 change: 1 addition & 0 deletions packages/realm-react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const SomeComponent = () => {
```

### Fixed
* Implicit children [was removed from `React.FC`](https://solverfox.dev/writing/no-implicit-children/). Children has now been explicitly added to provider props. ([#4565](https://github.com/realm/realm-js/issues/4565))
* Fixed potential "Cannot create asynchronous query while in a write transaction" error with `useObject` due to adding event listeners while in a write transaction ([#4375](https://github.com/realm/realm-js/issues/4375), since v0.1.0)

### Compatibility
Expand Down
4 changes: 3 additions & 1 deletion packages/realm-react/src/AppProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ const AppContext = createContext<Realm.App | null>(null);
* can be used to create a Realm.App instance:
* https://www.mongodb.com/docs/realm-sdks/js/latest/Realm.App.html#~AppConfiguration
*/
type AppProviderProps = Realm.AppConfiguration;
type AppProviderProps = Realm.AppConfiguration & {
children: React.ReactNode;
};

/**
* React component providing a Realm App instance on the context for the
Expand Down
1 change: 1 addition & 0 deletions packages/realm-react/src/RealmProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type PartialRealmConfiguration = Omit<Partial<Realm.Configuration>, "sync"> & {

type ProviderProps = PartialRealmConfiguration & {
fallback?: React.ComponentType<unknown> | React.ReactElement | null | undefined;
children: React.ReactNode;
};

/**
Expand Down
1 change: 1 addition & 0 deletions packages/realm-react/src/UserProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const UserContext = createContext<Realm.User | null>(null);
type UserProviderProps = {
// Optional fallback component to render when unauthenticated
fallback?: React.ComponentType<unknown> | React.ReactElement | null | undefined;
children: React.ReactNode;
};

/**
Expand Down
4 changes: 3 additions & 1 deletion packages/realm-react/src/__tests__/RealmProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ describe("RealmProvider", () => {
</View>
{toggleComponent && (
<View testID="secondRealmProvider">
<RealmProvider></RealmProvider>
<RealmProvider>
<View />
</RealmProvider>
</View>
)}
<Button testID="toggle" title="toggle" onPress={() => setToggleComponent(!toggleComponent)} />
Expand Down