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 07 '22 edited Aug 07 '22
That is amazing. I switch
[text "hello"]to[:f> text "hello"].And the error go away :D However it still don't work :PNow is the problem is when I console.log the
twfunction like so:(js/console.log (tw "mt-12"))I get:
ƒ (_classNames) {return {};}So I'm getting close. It seems like
tailwind/TailwindProvider {:utilities tailwind-json}is wrong. I tested the tailwind-json and it looks alright when I console.log it.{pb-12: style: {paddingBottom: 48} ...}This is how it looks for each tailwind class that I have in the app.
Seems to me that useTailwind and TailwindProvider can't talk with each other.
I updated github.