preactjs / signals

Manage state with style in every framework
https://preactjs.com/blog/introducing-signals/
MIT License
3.62k stars 88 forks source link

@preact/signals-react-transform not working in React Native #575

Open phanthaoIT opened 1 week ago

phanthaoIT commented 1 week ago

Environment

Describe the bug I added babel plugin but it doesn't work in React Native. it throws error: Cannot import useSignals outside of an ESM module file

image image
rschristian commented 1 week ago

Can you provide any reproduction? Our exports look to be correct, this is likely a tooling issue on your end.

Do you mean to use require instead?

phanthaoIT commented 1 week ago

Hi @rschristian, I followed the guide to add Babel transform, My project is just a React Native app but the babel has the errorCannot import useSignals outside of an ESM module file . The signal can work but I need to add manual import { useSignals } from '@preact/signals-react/runtime';.

rschristian commented 1 week ago

My project is just a React Native app

We need an actual reproduction in order to help, this isn't enough to go on.

We do ship both CJS & ESM builds, your config may be pulling the wrong one?