Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial signal value react native input field not showing #571

Open
2 of 5 tasks
SupertigerDev opened this issue Jun 19, 2024 · 14 comments
Open
2 of 5 tasks

Initial signal value react native input field not showing #571

SupertigerDev opened this issue Jun 19, 2024 · 14 comments
Labels

Comments

@SupertigerDev
Copy link

  • Check if updating to the latest version resolves the issue

Environment

  • I am using @preact/signals-core
  • I am using @preact/signals
  • I am using @preact/signals-react

Describe the bug
On web, it works fine. the input field shows the existing signal value. but on ios/android, the initial signal value does not show.

To Reproduce
https://snack.expo.dev/PWLDLLtxZpvpWq2hW_OKT?platform=web

Steps to reproduce the behavior:

  1. Go to the url above
  2. go to the web version and see that its working as intended, the input field contains "test"
  3. go to android/ios, see that the input field is empty.

Expected behavior
The input field for ios/android should contain the word "test" just like in the web version.

@SupertigerDev SupertigerDev changed the title Not working properly on android/ios Initial signal value react native input field not working. Jun 19, 2024
@SupertigerDev SupertigerDev changed the title Initial signal value react native input field not working. Initial signal value react native input field not showing Jun 19, 2024
@rschristian
Copy link
Member

Looks like unwrapping the signal works, issue with the binding in RN I guess.

@SupertigerDev
Copy link
Author

Looks like unwrapping the signal works, issue with the binding in RN I guess.

Unwrapping it also has bugs. I can't input text on android/iPhone

@rschristian
Copy link
Member

You checked the "I understand usage changed in v2, and I've followed the React Integration instructions" box yet I don't see any indication of using the Babel plugin or useSignals()

@SupertigerDev
Copy link
Author

Oh my apologies, I assumed the stuff in readme was the latest. I will try again with useSignal and give you an update later.

@SupertigerDev
Copy link
Author

Is the Babel stuff optional if I just use useSignal?

@rschristian
Copy link
Member

The ReadMe does document the latest usage, you just seem to have skipped over it.

useSignals(), plural. You need to use it or the Babel plugin.

@SupertigerDev
Copy link
Author

Oh, by the way, the hyperlink for the issue template React Integration instructions points to a 404 page

@rschristian
Copy link
Member

Yup, realized that. My bad #573

@SupertigerDev
Copy link
Author

SupertigerDev commented Jun 22, 2024

Ah, seems like I missread something. there is useSignal and useSignals which i did not realize because of their names being VERY similar. My bad.

Although, I'm not sure what is going on here. Is this an expo issue?
image
image

@rschristian
Copy link
Member

Looks like they don't support package exports? That's a bit rough, I suppose you can try forming the path manually?

@SupertigerDev
Copy link
Author

Annoyingly that didnt work either 😦 let me really quickly create a new react native project without expo 1 sec

@SupertigerDev
Copy link
Author

SupertigerDev commented Jun 22, 2024

Well, its working, however its not finegrained. Other elements also update. Unless its not intended to be finegrain like solidjs? Am i missunderstanding?

explorer_aNbSnmnWZb

export default function App() {
  useSignals();
  return (
    <SafeAreaView style={styles.container}>
      <TextInput
        style={styles.input}
        value={testSignal.value}
        onChangeText={e => (testSignal.value = e)}
      />
      <Text>
        <>{testSignal}</>
      </Text>
      <Text>{Math.random()}</Text>
    </SafeAreaView>
  );
}

@rschristian
Copy link
Member

however its not finegrained

Yes, if you unwrap with .value you de-opt into full component renders.

However, if RN is borked then this is all that I can recommend at the moment. RN isn't something we directly support / test against.

@SupertigerDev
Copy link
Author

yea its broken when i dont unwrap 😭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants