r/Clojurescript • u/Individual_Hunt8437 • Aug 07 '22
React Native with Tailwind in ShadowJS
I'm stuck trying to add tailwind to my react native project.
I have create a repo with the problem: mattrybin/clojurescript-tailwind-with-react-native
What I'm trying todo is to add vadimdemedes/tailwind-rn to my clojurescript project.
I do all the steps until step 7: Use Tailwind in React Native!
import {useTailwind} from 'tailwind-rn';
const MyComponent = () => {
const tailwind = useTailwind();
return <Text style={tailwind('text-blue-600')}>Hello world</Text>;
};
I'm new to clojure so this is my attempt based this article: react-hooks-raw
(ns example.components.my-component
(:require ["react-native" :as rn]
["tailwind-rn" :as tailwind]))
(defn text [text]
(let [tw tailwind/useTailwind]
[:> rn/View (:style (tw "flex-1"))
[:> rn/Text text]]))
I get the error: Error: Invalid hook call. Hooks can only be called inside of the body of a function component.
How can I use useTailwind in my project?
View all comments
Show parent comment
1
u/Individual_Hunt8437 Aug 08 '22
Amazing :D Thank you! That is right, I didn't wrap it and hook call was the problem.
I updated the Github with correct solution!
If anyone has this problem please go to:
app.cljs: https://github.com/mattrybin/clojurescript-tailwind-with-react-native/blob/master/src/main/example/app.cljs
my_component.cljs: https://github.com/mattrybin/clojurescript-tailwind-with-react-native/blob/master/src/main/example/components/my_component.cljs
Thanks u/dimchu and u/vadimdemedes