如何在单独的样式表中使用react-native-active-dimensions

时间:2019-11-06 19:02:29

标签: reactjs react-native react-hooks

我是React和React Native的新手。我有一个名为SiteStyle.js的样式表和一个名为react-native-responsive-dimensions的npm组件。我试图使用样式表中包含的钩子,但始终收到错误消息:“无效的钩子调用。只能在函数组件的主体内部调用钩子...”如何调用钩子我单独的样式表?

SiteStyle.js

   int[,] array1 = new int[6, 6]
        {
            {10, 20, 10, 20, 21, 99 },
            {2, 27, 5, 45, 20, 13 },
            {17, 20, 20, 33, 33, 20 },
            {21, 35, 15, 54, 20, 37 },
            {31, 101, 25, 55, 26, 66 },
            {45, 20, 44, 12, 55, 98 }
        };

        int Length = array1.GetLength(0);
        int Height = array1.GetLength(1);
        Console.WriteLine("  Col 0  Col 1  Col 2  Col 3  Col 4  Col 5");
        for (int i = 0; i < Length; i++)
        {
            for (int j = 0; j < Height; j++)
            {
                Console.Write(string.Format("{0,6} ", array1[i, j]));
            }
            Console.Write("\n" + "\n");
        }

        Console.ReadKey();

我在名为Home.js的文件中使用样式表,如下所示:

import { StyleSheet } from 'react-native'
import { useResponsiveFontSize } from "react-native-responsive-dimensions";

export default StyleSheet.create({
 homeCardTitle: {
    color: '#ffffff', 
    fontSize: useResponsiveFontSize(1)
  },
  ...
})

0 个答案:

没有答案