rescript-react-native / rescript-react-navigation

ReScript bindings for React Navigation
MIT License
74 stars 28 forks source link

Binding for Stack-component render-callback . #31

Closed a-c-sreedhar-reddy closed 4 years ago

a-c-sreedhar-reddy commented 4 years ago

Feature request

https://reactnavigation.org/docs/hello-react-navigation#passing-additional-props

Stack component can accept render callback instead of component prop.

eg:

<Stack.Screen name="Home">
  {props => <HomeScreen {...props} extraData={someData} />}
</Stack.Screen>
a-c-sreedhar-reddy commented 4 years ago
  module Screen = {
    type componentProps = {navigation};
    type renderCallbackProp = {
      navigation,
      route,
    };
    [@bs.obj]
    external makeProps:
      (
        ~name: string,
        ~options: optionCallback=?,
        ~initialParams: M.params=?,
        ~component: React.component({
                      .
                      "navigation": navigation,
                      "route": route,
                    })
                      =?,
        ~children: renderCallbackProp => React.element=?,
        unit
      ) =>
      screenProps(M.params);
    let make = stack##"Screen";
  };

How can I make sure that either component or children is given as props? Both of them should not be undefined and both of them should not be provided.