Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ReScript bindings for React Navigation

License

NotificationsYou must be signed in to change notification settings

rescript-react-native/rescript-react-navigation

 
 

Repository files navigation

Build StatusVersionChat

ReasonML /BuckleScript bindings forreact-navigation.

Exposed asReactNavigation module.

reason-react-navigation X.y._ means it's compatible withreact-navigationX.y._

Status

⚠️ Work in progress. These bindings are used successfully in several apps, butare not complete yet and still subject to change.

Example

An example project is available atnavigation-example.

Installation

Whenreact-navigation isproperly installed & configured by following their installation instructions,you can install the bindings:

npm install reason-react-navigation#oryarn add reason-react-navigation

reason-react-navigation should be added tobs-dependencies in yourbsconfig.json. Something like

{  //...  "bs-dependencies": [    "reason-react",    "reason-react-native",    // ...+    "reason-react-navigation"  ],  //...}

Example

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

openReactNative;openReactNavigation;[@react.component]letmake= (~navigation, ~screenProps)=> {  <Text> {React.string("Hello world!")} </Text>;};make->NavigationOptions.setDynamicNavigationOptions(params=> {letnavigation= params##navigation;letnavigationOptions= params##navigationOptions;letscreenProps= 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):

openReactNavigation;letroutes= {"Screen1":Screen1.make,"Screen2":Screen2.make,"Screen3":Screen3.make,};letnavigator=StackNavigator.make(routes);navigator->NavigationOptions.setNavigationOptions(NavigationOptions.t(~gesturesEnabled=false,()),);

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

openReactNavigation;moduleMyAppContainer=AppContainer.Make({typescreenProps= {. "someProp":int};letnavigator=MyStackNavigator.navigator;  });[@react.component]letmake=()=> {letscreenProps= {"someProp":42};  <MyAppContainer screenProps />;};

Alternatively (without a functor, but usingReact.createElement):

openReactNavigation;letappContainer=AppContainer.makeAppContainer(MyStackNavigator.navigator);[@react.component]letmake=()=> {letscreenProps= {"someProp":42};React.createElement(    appContainer,AppContainer.makeProps(~screenProps,()),  );};

Changelog

Check thechangelog for more informations about recentreleases.

Contribute

Read thecontribution guidelines before contributing.

Code of Conduct

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

Sponsor this project

 

Contributors82


[8]ページ先頭

©2009-2025 Movatter.jp