forked from nativewind/nativewind
-
Notifications
You must be signed in to change notification settings - Fork 0
/
snack.txt
58 lines (56 loc) · 2.04 KB
/
snack.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* 🗣️ Do as I say 📝, not as I do 🚫🤷♂️.
*
* Expo Snack does not allow setting the JSX runtime to automatic, or running a custom server.
* Therefore these demos utilize undocumented & unstable APIs that should not be used!
*
* These examples are for demonstrative purposes only. They have known bugs/issues and are not
* representative of NativeWind.
*
* Please do not use these APIs in your own projects.
*/
// var tailwindScriptLoaded = Platform.OS !== "web";
// if (Platform.OS === "web") {
// var tailwindScript = document.createElement("script");
// tailwindScript.addEventListener("load", () => {
// tailwindScriptLoaded = true;
// });
// tailwindScript.setAttribute("src", "https://cdn.tailwindcss.com");
// document.body.appendChild(tailwindScript);
// } else {
// StyleSheet.unstable_hook_onClassName = (content) => {
// fetch(`http://localhost:3000/api/compile`, {
// method: "POST",
// headers: {
// "Content-Type": "application/json",
// },
// body: JSON.stringify({ content }),
// })
// .then((response) => response.json())
// .then((body) => {
// StyleSheet.register(body);
// })
// .catch((error) => {
// console.warn(error.message);
// });
// };
// }
// (globalThis as any).isExpoSnack = true;
// const render = (element: any, { children, ...props }: any, key?: string) => {
// children = Array.isArray(children) ? children : [children];
// return createElement(element, { key, ...props }, ...children);
// };
// export const View = unstable_styled(RNView, render);
// export const Text = unstable_styled(RNText, render);
// export const Pressable = unstable_styled(RNPressable, render);
// export function withExpoSnack(Component: any) {
// return function () {
// const [, rerender] = useState(false);
// useEffect(() => {
// return tailwindScript?.addEventListener("load", () => {
// rerender(true);
// });
// }, []);
// return tailwindScriptLoaded ? <Component /> : <></>;
// };
// }