Skip to content

Commit

Permalink
Update Example and Templates (#6099)
Browse files Browse the repository at this point in the history
  • Loading branch information
takameyer authored Aug 25, 2023
1 parent 4715caa commit 3095fe6
Show file tree
Hide file tree
Showing 36 changed files with 190 additions and 251 deletions.
6 changes: 2 additions & 4 deletions example/app/components/LoginScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,17 @@ export const LoginScreen = () => {
placeholder="Password"
/>
</View>

{result?.error?.operation === AuthOperationName.LogIn && (
{result?.error?.operation ===
AuthOperationName.LogInWithEmailPassword && (
<Text style={[styles.error]}>
There was an error logging in, please try again{' '}
</Text>
)}

{result?.error?.operation === AuthOperationName.Register && (
<Text style={[styles.error]}>
There was an error registering, please try again
</Text>
)}

<View style={styles.buttons}>
<Pressable
onPress={() => logInWithEmailPassword({email, password})}
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ PODS:
- React-jsi (= 0.71.7)
- React-logger (= 0.71.7)
- React-perflogger (= 0.71.7)
- RealmJS (12.0.0-alpha.2):
- RealmJS (12.0.0):
- React
- SocketRocket (0.6.0)
- Yoga (1.14.0)
Expand Down Expand Up @@ -625,7 +625,7 @@ SPEC CHECKSUMS:
React-RCTVibration: 08f132cad9896458776f37c112e71d60aef1c6ae
React-runtimeexecutor: c5c89f8f543842dd864b63ded1b0bbb9c9445328
ReactCommon: dbfbe2f7f3c5ce4ce44f43f2fd0d5950d1eb67c5
RealmJS: 496714a3baf2ba320af9e558b205281607ec1fd3
RealmJS: fd89f477b8469188d45243c85bad4e0936d74457
SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
Yoga: d56980c8914db0b51692f55533409e844b66133c
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

12 changes: 5 additions & 7 deletions templates/expo-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,16 @@ Simple Expo template to quickly get started with Realm.

## 🚀 How to use

If you haven't already, install the `expo-cli`:
```
npm install --global expo-cli
```
Use the following command to generate your template:

```
yarn global add expo-cli
npx create-expo-app MyAwesomeRealmApp --template @realm/expo-template
```

Then use the following command to generate your template:
NOTE: version of `npm` before v9 may cause problems when initializing the template. If the initialization fails, please upgrade to the latest `npm` and try again.

```
expo init MyAwesomeRealmApp --template @realm/expo-template
npm install -g npm
```
## 🏃 How to build and run locally

Expand Down
2 changes: 1 addition & 1 deletion templates/expo-template/app/components/LoginScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const LoginScreen = () => {
/>
</View>

{result?.error?.operation === AuthOperationName.LogIn && (
{result?.error?.operation === AuthOperationName.LogInWithEmailPassword && (
<Text style={[styles.error]}>
There was an error logging in, please try again{' '}
</Text>
Expand Down
16 changes: 8 additions & 8 deletions templates/expo-template/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"name": "@realm/expo-template",
"version": "0.6.0",
"version": "0.7.0",
"description": "Realm Template for Expo",
"scripts": {
"start": "expo start --dev-client",
"android": "expo run:android",
"ios": "expo run:ios"
},
"dependencies": {
"@realm/react": "^0.5.1",
"expo": "~48.0.18",
"expo-dev-client": "~2.2.1",
"expo-splash-screen": "~0.18.2",
"expo-status-bar": "~1.4.4",
"@realm/react": "^0.6.0",
"expo": "^49.0.8",
"expo-dev-client": "~2.4.8",
"expo-splash-screen": "~0.20.5",
"expo-status-bar": "~1.6.0",
"react": "18.2.0",
"react-native": "0.71.8",
"react-native": "0.72.4",
"react-native-get-random-values": "~1.9.0",
"realm": "11.10.1"
"realm": "12.0.0"
},
"devDependencies": {
"@babel/core": "^7.22.5",
Expand Down
2 changes: 1 addition & 1 deletion templates/react-native-template/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@realm/react-native-template",
"version": "0.6.0",
"version": "0.7.0",
"description": "Realm Template for React Native",
"scripts": {
"lint": "cd template && npm run lint"
Expand Down
4 changes: 2 additions & 2 deletions templates/react-native-template/template/Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby File.read(File.join(__dir__, '.ruby-version')).strip
ruby ">= 2.6.10"

gem 'cocoapods', '~> 1.11', '>= 1.11.3'
gem 'cocoapods', '~> 1.12'
98 changes: 0 additions & 98 deletions templates/react-native-template/template/Gemfile.lock

This file was deleted.

85 changes: 85 additions & 0 deletions templates/react-native-template/template/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
Simple React Native template to quickly get started with Realm.

This app implements a simple todo list, using Realm for persistence and the [Realm React](https://github.com/realm/realm-js/tree/master/packages/realm-react) hooks for React integration. It supports sync, allowing users to login and sync their todo lists across multiple devices.

# Getting Started

>**Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding.
## 🔀 Setting up sync

See https://github.com/realm/realm-js/blob/main/templates/docs/sync-setup.md for instructions.

## Step 1: Start the Metro Server

First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native.

To start Metro, run the following command from the _root_ of your React Native project:

```bash
# using npm
npm start

# OR using Yarn
yarn start
```

## Step 2: Start your Application

Let Metro Bundler run in its _own_ terminal. Open a _new_ terminal from the _root_ of your React Native project. Run the following command to start your _Android_ or _iOS_ app:

### For Android

```bash
# using npm
npm run android

# OR using Yarn
yarn android
```

### For iOS

```bash
# using npm
npm run ios

# OR using Yarn
yarn ios
```

If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly.

This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.

## Step 3: Modifying your App

Now that you have successfully run the app, let's modify it.

1. Open `App.tsx` in your text editor of choice and edit some lines.
2. For **Android**: Press the <kbd>R</kbd> key twice or select **"Reload"** from the **Developer Menu** (<kbd>Ctrl</kbd> + <kbd>M</kbd> (on Window and Linux) or <kbd>Cmd ⌘</kbd> + <kbd>M</kbd> (on macOS)) to see your changes!

For **iOS**: Hit <kbd>Cmd ⌘</kbd> + <kbd>R</kbd> in your iOS Simulator to reload the app and see your changes!

## Congratulations! :tada:

You've successfully run and modified your React Native App. :partying_face:

### Now what?

- If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps).
- If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started).

# Troubleshooting

If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.

# Learn More

To learn more about React Native, take a look at the following resources:

- [React Native Website](https://reactnative.dev) - learn more about React Native.
- [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment.
- [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**.
- [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts.
- [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import 'react-native';
import React from 'react';
import App from '../App';

// Note: import explicitly to use the types shiped with jest.
import {it} from '@jest/globals';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

Expand Down
2 changes: 1 addition & 1 deletion templates/react-native-template/template/_eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
root: true,
extends: '@react-native-community',
extends: '@react-native',
};
3 changes: 3 additions & 0 deletions templates/react-native-template/template/_gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,6 @@ yarn-error.log

# Temporary files created by Metro to check the health of the file watcher
.metro-health-check*

# testing
/coverage
1 change: 0 additions & 1 deletion templates/react-native-template/template/_node-version

This file was deleted.

1 change: 0 additions & 1 deletion templates/react-native-template/template/_ruby-version

This file was deleted.

2 changes: 1 addition & 1 deletion templates/react-native-template/template/_watchmanconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{}
Loading

0 comments on commit 3095fe6

Please sign in to comment.