3
31%
MIT
bucklesript bindings for react-native-modal

bs-react-native-modal

this is a binding of react-native-modal

Usage

see the rei for detail documentation

module ModalTester = {
  open BsReactNative;
  type state = {isModalVisible: bool};
  type action =
    | ToggleModal;

  let component = ReasonReact.reducerComponent("ModalTester");
  let make = _children => {
    ...component,
    initialState: () => {isModalVisible: false},
    reducer: (action, state) =>
      switch (action) {
      | ToggleModal =>
        ReasonReact.Update({isModalVisible: !state.isModalVisible})
      },
    render: self =>
      <View>
        <TouchableOpacity onPress={() => self.send(ToggleModal)}>
          <Text value="Show Modal" />
        </TouchableOpacity>
        <ReactNativeModal isVisible={self.state.isModalVisible}>
          <View>
            <Text value="Hello!" />
            <TouchableOpacity onPress={() => self.send(ToggleModal)}>
              <Text value="Hide Me" />
            </TouchableOpacity>
          </View>
        </ReactNativeModal>
      </View>,
  };
};

Installation

Use yarn or npm

$ yarn add bs-react-native-modal

Then update your bsconfig.json

{
  "bs-dependencies": ["bs-react-native-modal"]
}