Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/react native docs v1.8 (#632)
* documentation for Beagle React Native * Update content/en/resources/customization/beagle-for-react-native/localhost.md Co-authored-by: Matheus Ribeiro Lima <57918064+matheusribeirozup@users.noreply.github.com> * Update content/pt/resources/customization/beagle-for-react-native/localhost.md Co-authored-by: Matheus Ribeiro Lima <57918064+matheusribeirozup@users.noreply.github.com> Co-authored-by: Tiago Peres França <tiago.franca@zup.com.br> Co-authored-by: Tiago Peres França <tiagoperesfr@gmail.com> Co-authored-by: Matheus Ribeiro Lima <57918064+matheusribeirozup@users.noreply.github.com>
- Loading branch information
1 parent
1fab96b
commit 3c0cdd4
Showing
28 changed files
with
786 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
title: React Native | ||
weight: 12 | ||
description: >- | ||
Here, you'll find how to install Beagle on your React Native application. | ||
--- | ||
|
||
--- | ||
|
||
## Introduction | ||
This guide considers you're familiar with React Native. If this is not the case, please check the | ||
[React Native guide on how to install its dependencies and create your first application](https://reactnative.dev/docs/environment-setup). | ||
|
||
Beagle is available for React Native, but it's not stable yet. The development is incomplete and we | ||
still have some work to do before moving from beta versions. Unfortunately, our team is not big | ||
enough to make React Native a priority and because of this, the development is relatively slow. We | ||
decided to release a beta version anyway because we figured out if it's in interest of the | ||
community, it can help us finalize it. | ||
[Here]({{< ref path="/resources/customization/beagle-for-react-native/development" lang="en" >}}) | ||
you can find a list of everything that should be working properly and everything that still needs | ||
work. Help is very welcomed here! | ||
|
||
## Versioning | ||
All versions of Beagle RN (Beagle React Native) to be launched before the final stable version | ||
follows the pattern "0.x.y", where "x" represents the version of Beagle Web Core it uses. Since we | ||
are currently in version "1.7.0" of Beagle Web Core, the current version of Beagle RN is 0.7.0. "y" | ||
will be used to launch new versions that uses the same version of Beagle Web Core. | ||
|
||
## Compatibility | ||
Beagle RN Beta is guaranteed to work only with latest releases of React Native, i.e. | ||
version 0.64.1 or above. It is probably possible to support older versions, but it is not a priority | ||
right now. | ||
|
||
## Installation | ||
At the root of your React Native project, install it with npm or yarn. | ||
|
||
If you use yarn: | ||
```bash | ||
yarn add @zup-it/beagle-react-native | ||
``` | ||
|
||
If you use npm: | ||
```bash | ||
npm install @zup-it/beagle-react-native | ||
``` | ||
|
||
{{% alert color="success" %}} | ||
Well done! Your library was installed. Continue at | ||
[**how to use Beagle on React Native.**]({{< ref path="/get-started/using-beagle/react-native" lang="en" >}}) | ||
{{% /alert %}} | ||
|
||
## **Next Steps** | ||
|
||
In this section, you made Beagle's **initial installation** on your application! | ||
Now, keep configuring Beagle: | ||
|
||
👉 Go to | ||
[**initial configurations** ]({{< ref path="/get-started/using-beagle/react-native" lang="en" >}}) | ||
to enable the use of Beagle on your React Native project. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
--- | ||
title: React Native | ||
weight: 28 | ||
description: >- | ||
This section shows the initial walkthrough to use the Beagle library in React Native projects. | ||
--- | ||
|
||
--- | ||
|
||
## **Configuration** | ||
|
||
After you finish the installation, you need to **configure the React Native project to use Beagle.** | ||
To do this, just follow the guide below. | ||
|
||
Run one of the commands below to generate the files that will be used by the Beagle library. You can | ||
run the command according to your package manager (yarn or npm). | ||
|
||
**If you use yarn:** | ||
```text | ||
yarn beagle | ||
``` | ||
|
||
**If you use npm:** | ||
```text | ||
npx beagle | ||
``` | ||
|
||
If the files beagle create already exist, a question will be made asking if you wish to replace | ||
them or not. | ||
|
||
Two files are created after running this command: `src/app.tsx` and | ||
`src/beagle/beagle-service.ts`. The first is the entry point for your app, while the second is | ||
the beagle configuration. | ||
|
||
{{% alert color="warning" %}} | ||
Attention: we highly recommend the use of Typescript, that's why both files are generated using | ||
this language. If you want to use plain javascript, rename the files to `app.jsx` and | ||
`beagle-service.js`. Also remove all typing information. | ||
{{% /alert %}} | ||
|
||
{{% alert color="warning" %}} | ||
Attention: if you're using prettier and/or eslint, you'll probably have to format the generated | ||
files according to the project rules. You can also ignore the rules if you don't want to change | ||
the code. | ||
{{% /alert %}} | ||
|
||
To view the beagle application in action, make sure that your app renders the component `App` at | ||
`src/app.tsx`. If you created your project via `react-native init`, change your `index.js` file to | ||
the following: | ||
|
||
```javascript | ||
import {AppRegistry} from 'react-native'; | ||
import App from './src/app'; | ||
import {name as appName} from './app.json'; | ||
|
||
AppRegistry.registerComponent(appName, () => App); | ||
``` | ||
|
||
Your application is ready to be executed! Once run, the app should show a welcome message loaded | ||
remotely from `https://usebeagle.io/start/welcome`. | ||
|
||
{{% alert color="success" %}} | ||
Congrats, you have finished your first Beagle Screen! | ||
{{% /alert %}} | ||
|
||
## Other configurations | ||
|
||
- [Cache]({{< ref path="/resources/customization/beagle-for-react-native/cache" lang="en" >}}) | ||
- [WebView]({{< ref path="/resources/customization/beagle-for-react-native/web-view" lang="en" >}}) | ||
- [Accessing the localhost]({{< ref path="/resources/customization/beagle-for-react-native/localhost" lang="en" >}}) | ||
- [Local images]({{< ref path="/resources/customization/beagle-for-react-native/local-images" lang="en" >}}) | ||
|
||
👉 For more details on how to use the Beagle Config and the component BeagleRemoteView, please, | ||
check the [React guide]({{< ref path="/get-started/using-beagle/web/react" lang="en" >}}), it works | ||
exactly the same! | ||
|
||
👉 Beagle React Native is still Beagle Web! Everything in this documentation for Beagle Web is also | ||
valid for Beagle React Native. To go deeper into the lib, we suggest reading the articles under | ||
[resources > customization > Beagle for React Native]({{< ref path="/resources/customization/beagle-for-react-native" lang="en" >}}) | ||
as well as | ||
[resources > customization > Beagle for Web]({{< ref path="/resources/customization/beagle-for-web" lang="en" >}}) | ||
|
||
👉 If you wish to know the current development status of Beagle React Native, check it | ||
[here]({{< ref path="/resources/customization/beagle-for-react-native/development" lang="en" >}}). | ||
Contributions are welcomed! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
content/en/resources/customization/beagle-for-backend/_index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
content/en/resources/customization/beagle-for-backend/beagle-framework.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
content/en/resources/customization/beagle-for-backend/serialization.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
content/en/resources/customization/beagle-for-react-native/_index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
title: Beagle for React Native | ||
weight: 188 | ||
description: >- | ||
You will find here the main classes that are part of Beagle's framework for | ||
Beagle React Native. | ||
--- | ||
|
||
--- | ||
|
||
You will find here additional information about Beagle React Native. |
30 changes: 30 additions & 0 deletions
30
content/en/resources/customization/beagle-for-react-native/cache.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
title: Cache | ||
weight: 189 | ||
description: >- | ||
You will find here information of how to persist cache in Beagle React Native. | ||
--- | ||
|
||
--- | ||
|
||
By default, Beagle RN will only cache files temporally, i.e. as soon the app is closed, the cache | ||
will be lost. To make a persistent cache, you must provide an implementation of the interface | ||
`BeagleStorage`. Both `react-native/AsyncStorage` and `@react-native-async-storage/async-storage` | ||
implement this interface. We don't use React Native's default implementation because it's | ||
deprecated. | ||
|
||
If you need to persist the cache, we recommend using `@react-native-async-storage/async-storage`. To | ||
install it, follow the instructions | ||
[here](https://react-native-async-storage.github.io/async-storage/docs/install/). | ||
|
||
To use it with beagle, just add the following configuration to `src/beagle/beagle-service.ts`: | ||
|
||
```typescript | ||
import AsyncStorage from '@react-native-async-storage/async-storage' | ||
// ... | ||
|
||
export default createBeagleUIService({ | ||
// ... | ||
customStorage: AsyncStorage, | ||
}) | ||
``` |
58 changes: 58 additions & 0 deletions
58
content/en/resources/customization/beagle-for-react-native/development.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
title: Development status | ||
weight: 193 | ||
description: >- | ||
You will find here information about the current development status of Beagle React Native. | ||
--- | ||
|
||
--- | ||
|
||
## Current development status | ||
This is our current development status. Please help us get to a stable version! | ||
|
||
To contribute to this project, please use | ||
[this repository](https://github.com/ZupIT/beagle-web-react). | ||
|
||
### Core features | ||
Fully implemented. Renderization, context, custom components and custom actions all work! In truth, | ||
if you don't intend on using the default components and default actions, Beagle React Native is | ||
ready for production. | ||
|
||
### Components | ||
| Component | Status | Description | | ||
|----------------|-----------------|-------------------------------------------------------------------------------------------------| | ||
| Container | done | | | ||
| Screen | not implemented | Working as a container | | ||
| Button | done | | | ||
| Image | incomplete | There might be some problems with the image size. Placeholder is not implemented. | | ||
| TextInput | done | | | ||
| Lazy component | done | | | ||
| ListView | incomplete | Extremely buggy and slow. Mainly on Android. | | ||
| GridView | not implemented | | | ||
| PageView | incomplete | Doesn't render the children properly. Can't navigate between pages. | | ||
| SimpleForm | not implemented | Working as a container | | ||
| TabBar | incomplete | The tabbar doesn't scroll There seems to be a bug where a second tab bar in a page won't render | | ||
| Text | done | | | ||
| Touchable | done | | | ||
| WebView | done | | | ||
|
||
We also need to check the styling here. Some of the components, even the ones marked as done, have | ||
way to many styles, which might create some undesired behavior. | ||
|
||
### Actions | ||
| Actions | Status | Description | | ||
|-----------------|-----------------|------------------------------------------------------------------| | ||
| PushStack | incomplete | It works exactly like in web, i.e. the back button does nothing. | | ||
| PopStack | incomplete | It works exactly like in web, i.e. the back button does nothing. | | ||
| PushView | incomplete | It works exactly like in web, i.e. the back button does nothing. | | ||
| PopView | incomplete | It works exactly like in web, i.e. the back button does nothing. | | ||
| PopToView | incomplete | It works exactly like in web, i.e. the back button does nothing. | | ||
| ResetStack | incomplete | It works exactly like in web, i.e. the back button does nothing. | | ||
| OpenNativeRoute | not implemented | will try to use the browsers location, which doesn't exist. | | ||
| OpenExternalUrl | not implemented | will try to use the browsers location, which doesn't exist. | | ||
| AddChildren | done | | | ||
| Condition | done | | | ||
| Confirm | not implemented | | | ||
| SendRequest | done | | | ||
| SetContext | done | | | ||
| SubmitForm | not implemented | | |
43 changes: 43 additions & 0 deletions
43
content/en/resources/customization/beagle-for-react-native/local-images.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
title: Local images | ||
weight: 192 | ||
description: >- | ||
You will find here information on how to register your local images. | ||
--- | ||
|
||
--- | ||
|
||
Beagle components normally refer to images by an id, see the example below: | ||
|
||
```json | ||
{ | ||
"_beagleComponent_": "beagle:image", | ||
"path": { | ||
"_beagleImagePath_": "local", | ||
"mobileId": "zup-logo" | ||
} | ||
} | ||
``` | ||
|
||
Above, the image component refers to `zup-logo`. For this to work, this id must be registered in | ||
Beagle. To register images that can be used for beagle, you must provide a map in the configuration | ||
at `beagle-service.ts`. See the example below: | ||
|
||
```typescript | ||
import zupLogo from '../assets/zup-logo.png' | ||
// ... | ||
|
||
export default createBeagleUIService({ | ||
// ... | ||
localAssetsPath: { | ||
'zup-logo': zupLogo, | ||
}, | ||
}) | ||
``` | ||
|
||
The image must exist in your assets folder, in this case, located at `src/assets`. If Typescript | ||
complains, you can create a `src/globals.d.ts` file with the following content: | ||
|
||
```typescript | ||
declare module '*.png' | ||
``` |
Oops, something went wrong.