jotaijs / jotai-signal

MIT License
232 stars 3 forks source link

should it run on react-native? #9

Closed ph4un00b closed 1 year ago

ph4un00b commented 1 year ago

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

dai-shi commented 1 year ago

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

ph4un00b commented 1 year ago

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.

dai-shi commented 1 year ago

Thanks.

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

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

dai-shi commented 1 year ago

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

dai-shi commented 1 year ago

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?

ph4un00b commented 1 year ago

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.

ph4un00b commented 1 year ago

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

jotai-err
dai-shi commented 1 year ago

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";
ph4un00b commented 1 year ago

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.

dai-shi commented 1 year ago

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

ph4un00b commented 1 year ago

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

I suppose we could end this issue.

dai-shi commented 1 year ago

@ph4un00b that's great to know. thanks.

@muhammadaasim from https://github.com/dai-shi/zustand-signal/issues/13, this issue should be helpful for you.