简体   繁体   中英

Displaying MySQL data in a ReactNative application

I want to display the data from my MySQL database, in my React Native application.

I am able to display the data in an alert message. But not in the application (for example, in a tag).

How to do it?

The screenshot represents the display of data in an alert message: alert message

Thanks a lot!

You should use a Text component and access the object's comment_test property from it.

Without further code, I can only provide an example:

<View>
<Text>{mysqlResponseObject.comment_test}</Text>
<View>

Store the data in a state then iterate through it. Use can update your state with setData function where you read the data from the database.

    import React, { useState } from 'react';
    
    function Example() {
      const [data, setData] = useState([]);
    
      return (
        <View>
          {data.map((item) => (
            <Text>{item.comment_test}</Text>
          ))}
        </View>
      );
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM