Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/cca-io/bs-react-navigation

Reason bindings for react-navigation
https://github.com/cca-io/bs-react-navigation

bucklescript react react-navigation reason reasonml

Last synced: 3 months ago
JSON representation

Reason bindings for react-navigation

Awesome Lists containing this project

README

        

# bs-react-navigation

[Reason](https://reasonml.github.io) bindings to [react-navigation](https://github.com/react-navigation/react-navigation).

## Status

Superseded by https://github.com/rescript-react-native/rescript-react-navigation.

## Example

Instantiate a navigation module with your `screenProps` type (Navigation.re):

```reason
include ReactNavigation.Make({
type screenProps = {
.
"someProp": int,
};
});
```

A screen component with dynamic navigation options (Screen1.re):

```reason
open ReactNative;
open Navigation;

[@react.component]
let make = (~navigation, ~screenProps) => {
{React.string("Hello world!")} ,
};

make->setDynamicNavigationOptions(params => {
let navigation = params##navigation;
let navigationOptions = params##navigationOptions;
let screenProps = params##screenProps;

/* More properties can be set dynamically based on navigation, navigationOptions or screenProps. */
NavigationOptions.t(~title="Screen 1", ~headerTintColor="red", ());
});
```

A stack navigator containing this screen (MyStackNavigator.re):

```reason
open Navigation;

let routes = {
"Screen1": Screen1.make,
"Screen2": Screen2.make,
"Screen3": Screen3.make,
};

let navigator = StackNavigator.make(routes);
navigator->setNavigationOptions(NavigationOptions.t(~gesturesEnabled=false, ()));
```

The main React component of the app (App.re):

```reason
open Navigation;

module AppContainer = (val makeAppContainer(MyStackNavigator.navigator));

[@react.component]
let make = () => {
let screenProps = {"someProp": 42};

;
};
```