# Modal

可以用 react-native-modal 模組，但在 native-base 下可能有問題，可以用原生替代。

{% embed url="<https://stackoverflow.com/questions/56941252/native-base-and-modal-not-working-in-react-native>" %}

## 範例

```javascript
 <View style={{ flex: 1 }}>
   <Modal 
     onRequestClose={() => this.setState({})}
     transparent={true} 
     animationType={"slide"} 
     visible={true}>
                <View
                  style={{
                    flex: 1,
                    justifyContent: "center",
                    alignItems: "center",
                    backgroundColor: 'rgba(0,0,0,0.5)'
                  }}
                >
                  <View style={styles.ModalInsideView}>
                    <Text
                      style={{
                        color: "black",
                        fontSize: 14,
                        fontWeight: "700",
                      }}
                    >
                      Hello{" "}
                    </Text>
                  </View>
                </View>
   </Modal>
</View>

const styles = {
  ModalInsideView: {
    justifyContent: "center",
    alignItems: "center",
    backgroundColor: "white",
    height: 245,
    width: "90%",
    borderRadius: 10,
    borderWidth: 1,
    borderColor: "#fff",
  },
};

```

![](/files/-MJkmGIttd_FD2z2Dfwl)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://easonwang.gitbook.io/web_advance/react-native/yuan-sheng-zu-jian/modal.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
