reactjs Tailwind -类型错误:undefined不是函数

cu6pst1q  于 2023-05-22  发布在  React
关注(0)|答案(1)|浏览(137)

刚开始学习react native,就被这个错误卡住了。IOS App emulatorTerminal

import React from "react";
import { StyleSheet, Text, View } from 'react-native';
import tw from "tailwind-rn"

export default function App() {
  return (
    <View style={tw("flex-1 justify-center items-center")}>
      <Text>Hello</Text>
      <button title="Click me" />
    </View>
  );
}

想试试顺风。已安装所有依赖项。

e4yzc0pl

e4yzc0pl1#

tailwind-rn的用法说明你应该导入useTailwind钩子:

import React from "react";
import { StyleSheet, Text, View } from 'react-native';
import { useTailwind } from 'tailwind-rn';

export default function App() {
  const tw = useTailwind();

  return (
    <View style={tw("flex-1 justify-center items-center")}>
      <Text>Hello</Text>
      <button title="Click me" />
    </View>
  );
}

相关问题