GithubHelp home page GithubHelp logo

rescript-react-native / rescript-react-navigation Goto Github PK

View Code? Open in Web Editor NEW
73.0 6.0 27.0 5.31 MB

ReScript bindings for React Navigation

License: MIT License

JavaScript 15.77% ReScript 84.23%
react rescript rescript-react rescript-react-native react-native navigation react-navigation hacktoberfest

rescript-react-navigation's Introduction

rescript-react-native

Build Status Version ReScript Forum

ReScript bindings for React Native.

Allows to use ReScript with ReScript React to make your iOS, Android and Web apps.

Getting Started

Check our getting started guide for details.

Documentation

See https://rescript-react-native.github.io/.


Changelog

Check the changelog for more informations about recent releases.

Contribute

Read the contribution guidelines before contributing.

Code of Conduct

We want this community to be friendly and respectful to each other. Please read our full code of conduct so that you can understand what actions will and will not be tolerated.

rescript-react-navigation's People

Contributors

arnarthor avatar baransu avatar bjornj12 avatar chenglou avatar cknitt avatar czystyl avatar dckt avatar dependabot[bot] avatar fakenickels avatar fhammerschmidt avatar freddy03h avatar grabbou avatar gunnigylfa avatar jamieparkinson avatar johannth avatar kristinns avatar mcanobbiotr avatar mciparelli avatar medson10 avatar mobily avatar moox avatar rikkiabb avatar saschatimme avatar sgny avatar szymonzmyslony avatar trancever avatar ulrikstrid avatar vnovick avatar wokalski avatar zamotany avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rescript-react-navigation's Issues

Error: Unable to resolve module `./Interop`

New issue since 5.0.1

error: Error: Unable to resolve module `./Interop` from `node_modules/reason-react-navigation/src/Stack.bs.js`:

I think it's relative to this commit because I didn't get this issue on my branch : 64d12bb

Something error was happened at building project

summary

I copied Example.re as root file App.re, in local project.
I can't run "yarn re:build", alias of "bsb -clean-world -make-world"

The problem

The stdout result is below.

$ yarn bsb -clean-world -make-world
Cleaning... 50 files.
Cleaning... 572 files.
Cleaning... 9 files.
Cleaning... 2 files.
[37/37] Building src/ReactDOMRe.cmj
[366/366] Building src/apis/Animated-ReactNative.cmj
[2/34] Building src/Core.reast
FAILED: src/Core.reast 
<project_path>/node_modules/bs-platform/lib/bsc.exe  -w -30-40+6+7+27+32..39+44+45+101+102-105 -color always -bs-jsx 3 -bs-quiet -bs-no-version-header -o src/Core.reast -bs-syntax-only -bs-binary-ast <project_path>/node_modules/reason-react-navigation/src/Core.re
File "<project_path>/node_modules/reason-react-navigation/src/Core.re", line 31, characters 65-66:
Error: Unclosed "{" (opened line 16, column 56)

  We've found a bug for you!
 <project_path>/node_modules/reason-react-navigation/src/Core.re
  
  There's been an error running Reason's parser on a file.
  The error location should be slightly above this message.
  Please file an issue on github.com/facebook/reason. Thanks!
  
[11/34] Building src/NavigationActions.reast
FAILED: subcommand failed.
Failure: <project_path>/node_modules/bs-platform/lib/ninja.exe 
 Location: <project_path>/node_modules/reason-react-navigation/lib/bs
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

It seems that there is no syntax error in Core.re.
But I'm a begginer of ReasonML, so I cannot determine the exact cause.

How to reproduce

create reason react native app

$ npx @react-native-community/cli init --template @reason-react-native/template MyApp

add reason-react-navigation

$ yarn add reason-react-navigation 

add "reason-react-navigation" to bs-dependencies of bsconfig.json

then run

$ yarn bsb -clean-world -make-world

Environment

macOS Mojave 10.14.6
node v10.16.0
packages

"dependencies": {
    "react": "^16.9.0",
    "react-native": "^0.61.0",
    "reason-react": "^0.7.0",
    "reason-react-native": "^0.61.0",
    "reason-react-navigation": "^5.0.0-beta.0"
  },
  "devDependencies": {
    "@babel/core": "^7.6.2",
    "@babel/runtime": "^7.6.2",
    "@react-native-community/eslint-config": "^0.0.5",
    "babel-jest": "^24.9.0",
    "bs-platform": "^7.0.0",
    "eslint": "^6.5.1",
    "jest": "^24.9.0",
    "metro-react-native-babel-preset": "^0.56.0",
    "react-test-renderer": "16.9.0"
  },

How to properly type navigateParams

Hi! I am having some trouble figuring out how to properly navigate with params. The {..}=? is a bit alien to me and was hard to google :)

I have this Stack here, and I want to navigate to the TodoModal from the TodosIndex.

module TodoStackScreen = {
  include Stack.Make({
    type params = {todo: todo}
  })
  @react.component
  let make = (~navigation as _, ~route as _) => {
    <Navigator>
      <Group> <Screen name="TodosIndex" component=TodoIndex.make /> </Group>
      <Group screenOptions={_optionProps => options(~presentation=#modal, ())}>
        <Screen name="TodoModal" component=TodoView.make /> <View />
      </Group>
    </Navigator>
  }
}

Problem arises when trying to define params. I tried to type out todo in the above Stack.Make, but it doesn't seem to do the trick.

Skjermbilde 2021-12-12 kl  08 07 13

The error message is as follows:

The record field todo can't be found.

If it's defined in another module or file, bring it into scope by:
- Prefixing it with said module name: TheModule.todo
- Or specifying its type: let theValue: TheModule.theType = {todo: VALUE}
ReScript

Syntax errors compiling version 6

Hi :)

First of all, thanks a lot for maintaining the rescript-react-native ecosystem! I'm looking into it now in hopes of a more type-safe way to make RN apps. It seems super promising, and seems to have most of the bindings I need ๐Ÿฅ‡

I am having an issue compiling a working rescript-react-native project with the rescript-react-navigation bindings.

Here is a minimal reproducible repo, based on an expo starter: https://github.com/kodeFant/rescript-react-navigation-issue

I have tried to lock every version to version 6.0.0 to be sure it's all aligned, but does not seem to help.

When I try to run npm run re:clean-build, I get this error message:

Dependency on rescript-react-navigation
bsb: [2/37] src/Drawer.ast
FAILED: src/Drawer.ast

  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/Drawer.res:65:5-7
  
  63 โ”† 
  64 โ”† type drawerNavigationItemsProps = {
  65 โ”†   ...contentOptions,
  66 โ”†   "drawerPosition": string,
  67 โ”†   "getLabel": scene => React.element,
  
  I'm not sure what to parse here when looking at "...".


  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/Drawer.res:66:21
  
  64 โ”† type drawerNavigationItemsProps = {
  65 โ”†   ...contentOptions,
  66 โ”†   "drawerPosition": string,
  67 โ”†   "getLabel": scene => React.element,
  68 โ”†   "renderIcon": scene => React.element,
  
  I'm not sure what to parse here when looking at ":".


  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/Drawer.res:73:5-7
  
  71 โ”† 
  72 โ”† type contentComponentProps = {
  73 โ”†   ...drawerNavigationItemsProps,
  74 โ”†   "navigation": navigation,
  75 โ”†   "drawerOpenProgress": animatedNode,
  
  I'm not sure what to parse here when looking at "...".


  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/Drawer.res:74:17
  
  72 โ”† type contentComponentProps = {
  73 โ”†   ...drawerNavigationItemsProps,
  74 โ”†   "navigation": navigation,
  75 โ”†   "drawerOpenProgress": animatedNode,
  76 โ”† }
  
  I'm not sure what to parse here when looking at ":".

bsb: [8/37] src/BottomTabs.ast
FAILED: src/BottomTabs.ast

  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/BottomTabs.res:55:5-7
  
  53 โ”† 
  54 โ”† type bottomTabBarOptions = {
  55 โ”†   ...baseBottomTabBarOptions,
  56 โ”†   "activeTintColor": option<string>,
  57 โ”†   "inactiveTintColor": option<string>,
  
  I'm not sure what to parse here when looking at "...".


  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/BottomTabs.res:56:22
  
  54 โ”† type bottomTabBarOptions = {
  55 โ”†   ...baseBottomTabBarOptions,
  56 โ”†   "activeTintColor": option<string>,
  57 โ”†   "inactiveTintColor": option<string>,
  58 โ”† }
  
  I'm not sure what to parse here when looking at ":".


  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/BottomTabs.res:71:5-7
  
  69 โ”† 
  70 โ”† type bottomTabBarProps = {
  71 โ”†   ...baseBottomTabBarOptions,
  72 โ”†   "state": navigationState<M.params>,
  73 โ”†   "navigation": navigation,
  
  I'm not sure what to parse here when looking at "...".


  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/BottomTabs.res:72:12
  
  70 โ”† type bottomTabBarProps = {
  71 โ”†   ...baseBottomTabBarOptions,
  72 โ”†   "state": navigationState<M.params>,
  73 โ”†   "navigation": navigation,
  74 โ”†   "onTabPress": routeArgs => unit,
  
  I'm not sure what to parse here when looking at ":".

bsb: [10/37] src/MaterialTopTabs.ast
FAILED: src/MaterialTopTabs.ast

  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/MaterialTopTabs.res:60:5-7
  
  58 โ”† 
  59 โ”† type materialTopTabBarOptions = {
  60 โ”†   ...tabBar,
  61 โ”†   "activeTintColor": option<string>,
  62 โ”†   "inactiveTintColor": option<string>,
  
  I'm not sure what to parse here when looking at "...".


  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/MaterialTopTabs.res:61:22
  
  59 โ”† type materialTopTabBarOptions = {
  60 โ”†   ...tabBar,
  61 โ”†   "activeTintColor": option<string>,
  62 โ”†   "inactiveTintColor": option<string>,
  63 โ”†   "iconStyle": option<ReactNative.Style.t>,
  
  I'm not sure what to parse here when looking at ":".


  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/MaterialTopTabs.res:94:5-7
  
  92 โ”† 
  93 โ”† type materialTopTabBarProps = {
  94 โ”†   ...materialTopTabBarOptions,
  95 โ”†   "state": navigationState<M.params>,
  96 โ”†   "navigation": navigation,
  
  I'm not sure what to parse here when looking at "...".


  Syntax error!
  /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/src/MaterialTopTabs.res:95:12
  
  93 โ”† type materialTopTabBarProps = {
  94 โ”†   ...materialTopTabBarOptions,
  95 โ”†   "state": navigationState<M.params>,
  96 โ”†   "navigation": navigation,
  97 โ”†   "descriptors": descriptors,
  
  I'm not sure what to parse here when looking at ":".

bsb: [31/37] src/Example-ReactNavigation.cmj
FAILED: cannot make progress due to previous errors.
Failure: /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/bs-platform/darwin/ninja.exe 
Location: /Users/larslilloulvestad/kode/rescript-react-navigation-issues/node_modules/rescript-react-navigation/lib/bs
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ re:clean-build: `bsb -clean-world -make-world`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the @ re:clean-build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/larslilloulvestad/.npm/_logs/2021-12-08T03_08_09_505Z-debug.log

Example.re not compiling outside of repo

Example.re compiles while in the repo. Tried running it in a fresh project. Got:

// Example.re renamed to something else
// Uncomment this to compile this example outside of this repo
// in this example it's not necessary (since we are running it in the module repo itself)
include ReactNavigation;
...
61 โ”† <Navigator mode=`modal headerMode=`none>
  62 โ”†   <Screen name="Main" component=MainStackScreen.make />
  63 โ”†   <ScreenWithCallback name="MyModal">
  64 โ”†     {({navigation, route}) => <ModalScreen navigation route />}
  65 โ”†   </ScreenWithCallback>
  
  The module or file ScreenWithCallback can't be found.
  - If it's a third-party dependency:
    - Did you list it in bsconfig.json?
    - Did you run `bsb` instead of `bsb -make-world`
      (latter builds third-parties)?
  - Did you include the file's directory in bsconfig.json?
  
FAILED: subcommand failed.
>>>> Finish compiling(exit: 1)

Upgrade to React Navigation 6.0

React Navigation 6.0 is coming! But don't worry it's still in beta On the way to React Navigation 6.0

They also wrote a really clean upgrading post that will help us migrating Upgrading from 5.x

Interesting part I noticed is changes on the Linking config. For now we don't have linking config on the bindings, I created my own on my app but never backport it here because some weird case that lead to be to tied with the app in the end.
With changes on V6 I think it will be doable, I want to test it!

This upgrade will wait Rescript Migration #42 I think.

`Example.res` will make build broken.

The problem

How to reproduce

Some error likes these:

24 โ”‚   let make = (~navigation as _, ~route as _) =>
25 โ”‚     <Navigator>
26 โ”‚       <Screen
27 โ”‚         name="Home"
 . โ”‚ ...
42 โ”‚           )}
43 โ”‚       />
44 โ”‚     </Navigator>
45 โ”‚ }

  This record expression is expected to have type navigatorProps
  The field children does not belong to type navigatorProps

FAILED: cannot make progress due to previous errors.

Expected behavior

npm i and npm res:build and everything success

Actual behavior

build failure. but it works when delete Example.res from node_modules

Environment

"dependencies": {
  "@react-navigation/native": "^6.1.9",
  "@react-navigation/stack": "^6.3.20",
  "@rescript/react": "^0.11.0",
  "react": "18.2.0",
  "react-native": "0.72.0",
  "react-native-safe-area-context": "^4.8.2",
  "react-native-screens": "^3.29.0",
  "rescript-react-native": "^0.72.0",
  "rescript-react-navigation": "^6.0.3"
}

@react-navigation v5

We need to cover v5, bindings should be much simpler (because api is).

I will create a branch & a PR if I can make something usable (for now will keep them local to my project).

If anyone have something, please share even if that's WIP
poke @cem2ran @cknitt

Proposal : Linking API

Linking API

For my project I created a linking API but I'm far from zero cost binding, since ReScript 10 and optional record attribute, it's seems less shitty and I think it's cool to discuss to have experts opinions about it.

Proposal

type routeName = string

type rec pathConfig = {
  path?: string,
  exact?: bool,
  initialRouteName?: routeName,
  screens?: screens,
}
and screens = Js.Dict.t<pathConfig>

type config = {
  initialRouteName?: routeName,
  screens: screens,
}

type t = {
  enabled?: bool,
  prefixes: array<string>,
  config?: config,
}

type routeNameAndConfig = (routeName, pathConfig)

let makeScreens = (screens: array<routeNameAndConfig>): screens => screens->Js.Dict.fromArray

Example

let options = {
  prefixes: [WebConst.origin],
  config: {
    initialRouteName: "app",
    screens: [
      (
        "app",
        {
          screens: [
            ("news", {screens: [("newsList", {path: ""})]->makeScreens}),
            (
              "planning",
              {
                screens: [
                  (
                    "planningNav",
                    {
                      screens: [
                        ("planningNewList", {path: "planning/news"}),
                        ("planningList", {path: "planning"}),
                      ]->makeScreens,
                    },
                  ),
                ]->makeScreens,
              },
            ),
            (
              "catalogue",
              {
                screens: [
                  (
                    "catalogueNav",
                    {
                      screens: [
                        ("seriesList", {path: "series"}),
                        ("authorsList", {path: "authors"}),
                        ("publishersList", {path: "publishers"}),
                      ]->makeScreens,
                    },
                  ),
                ]->makeScreens,
              },
            ),
          ]->makeScreens,
        },
      ),
      (
        "modalNav",
        {
          screens: [
            ("volumeDetail", {path: "volumes/:id"}),
            ("editionDetail", {path: "editions/:id"}),
            ("serieDetail", {path: "series/:id"}),
            ("publisherDetail", {path: "publishers/:id"}),
            ("authorDetail", {path: "authors/:id"}),
          ]->makeScreens,
        },
      ),
      (
        "collectionPublic",
        {
          initialRouteName: "collectionPublicNav",
          path: "user/:username",
          screens: [
            (
              "collectionPublicNav",
              {
                screens: [
                  ("collectionPublicList", {path: "collection"}),
                  ("planningPersoPublicList", {path: "planning"}),
                  ("missingPublicList", {path: "missing"}),
                  ("wishPublicList", {path: "wish"}),
                ]->makeScreens,
              },
            ),
            ("collectionPublicEdition", {path: "edition/:editionId"}),
          ]->makeScreens,
        },
      ),
    ]->makeScreens,
  },
}

Add minimal docs

We should have something on the website. People are searching for this in "Search" bar without result atm.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.