jotaijs/jotai-signal

should it run on react-native?

ph4un00b opened this issue · 12 comments

Hello ✋, Very cool library, but I was wondering if the signals should work on react-native since I'm more into that workflow these days.
Right now i'm not able to display an expected value.

image

tsconfig
image

Hi, thanks for trying!
Technically, it should work on RN, but I never tried.
Can you create a small reproduction with expo snack?

hi Mr @dai-shi The jsxImportSource jotai-signal directive is not functioning in the expo snack that I have set up over here.
but it seems like the same issue.

https://snack.expo.dev/@phau/healthy-donut

If you need anything else, please let me know.

Thanks.

I just hand-compiled: https://snack.expo.dev/kjclneke1

You are right, it's not working... 🤔

I hope to find some time to work on it. It will take a while.

Hi, I tried to reproduce the bug locally, but it works well locally.
I downloaded the expo snack and run locally on web and iOS.

Also tried, codesandbox with react-native-web: https://codesandbox.io/s/priceless-star-kg7dmh?file=/src/App.js, it's working well.

What's missing? Can you help creating a reproduction?

Hi Mr., As I can see, a number of things happened last week.

The updated clients and the new SDK may result in improved compatibility.
I can't reproduce a not working sample anymore, the expo snack is the only way at the moment.

The only remaining issue is that the $(atom) shape is unable to function properly.

when I try to use the $(atom) shape it yields the error below on web or in device.
jotai-err

https://github.com/ph4un00b/jotai-signals-typescript

I think you just forgot the jsx pragma?

diff --git a/App.tsx b/App.tsx
index 3271b1c..8427f78 100644
--- a/App.tsx
+++ b/App.tsx
@@ -1,3 +1,5 @@
+/** @jsxImportSource jotai-signal */
+
 import { Text, View, StyleSheet, Button } from "react-native";
 import { atom } from "jotai/vanilla";
 import { useAtom, useSetAtom } from "jotai/react";

Yes, adding up the jsx pragma on the web, aka react-native-web, works really well 👾.

I also included the samples for hide/show and atom-signal and all worked on the web side.

📲Device mode is where the issue lies because Expo Go produces an error.

jotai-signal-go-err

I added the "jsxImportSource" on my tsconfig with no luck.

and only the handcompiled signals worked

that syntax error is due to that the bundler can't resolve jotai-signal/jsx-runtime. maybe, you need something in metro config.

Absolutely true, Mr. the jotai-signal configuration I introduced seems to have made all the difference; awesome! 🎉

I suppose we could end this issue.

@ph4un00b that's great to know. thanks.

@muhammadaasim from zustandjs/zustand-signal#13, this issue should be helpful for you.