-
Notifications
You must be signed in to change notification settings - Fork 1.8k
The future of React Native for Web #1538
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
Comments
Awesome transparency and really love the direction this is going, @necolas. Is there anything you're looking for in terms of code help from the community to get involved? |
Optimizing the existing hooks usage would be helpful at this point - any relevant use of |
thank you @necolas . This is very reassuring. I am sure many of us, the users, would like to help, in some capacity. |
Awesome |
The future is looking bright! 👏 If I could add a small wishlist item: This might also solve weird issues where SSR result differs from client rendering in style tags... Explanation: I wanted to use the class name generation and wrap |
@EyMaddis would you like to share your solution? 👍 thinking about the same to avoid jumpy layouts on SSR |
@kations here you go: https://gist.github.com/EyMaddis/35ae3b269e4658527a1f8e374bd434ac However, I get warnings that the server side style does not match the clients (react warning). Maybe somebody can fix that... ;) |
@necolas https://github.com/microsoft/reactxp/blob/master/src/web/Animated.tsx i think it's a good candidate for future development of react native web. EDIT: okay, this was an interesting read: |
Another more general comment about the future of RNW: I would also like to be able to use the full potential for a web platform. I could, of course, use a I would like a shift from a pure "native-first" approach to native and web APIs having a similar weight. I am willing to help, but don't feel that my contributions fully align with your intention, @necolas. Do I misinterpret this? Thanks |
There will not be any support for CSS classes or other APIs that break the guarantees provided. And I won't be arbitrarily adding APIs that go against the design principles of React and where we want to take it more generally. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I've published a new canary as version |
@necolas seeing an immediate issue when server-side rendering:
Looks like this line needs a Happy to open PRs if you're looking for them against the |
Thanks. Should be patched in PRs are good too. Little bugs like this I'll patch by amend/rebase of the original commit. Other things I can merge into |
@necolas looking good so far. No noticeable degradation in performance or unnecessary re-rendering that I can find: paularmstrong/build-tracker#193 Only about a 0.5KiB size increase, so that's helpful :) |
Looks like I've lost the ability to call |
That was possible before? I'm going to rewrite the Touchable stuff so that it uses onClick for onPress in the future though |
Yep, was using here: https://github.com/paularmstrong/build-tracker/blob/master/src/app/src/components/ComparisonTable/RevisionCell.tsx#L29 Triggered both by |
What does "lost the ability" mean exactly? |
Ah sorry, that was not clear. |
Oh that's weird. Thanks I'll look into it |
Looks like |
Very cool. Does this address the problem with onPress in a window scroll environment on mobile? It looks like the support of
|
Updated latest canary to |
Latest canary is |
@xcarpentier AsyncStorage was removed from 0.12 and isn't exported by React Native either anymore, so Expo might be aliasing to the wrong place and need updating |
@javascripter thanks for the test case. this should be fixed in |
Hi. Thanks for the fix. I think I noticed another issue. TextInput onSelectionChange doesn't seem to work properly in canary.
Google Chrome Version 81.0.4044.138 (Official Build) (64-bit) on Mac OS. Same in latest Safari on MacOS. The prop used to be called in 0.11.x when TextInput value changes. Same behavior in RN. |
That's weird because there's a test case for it in the docs that works as expected. |
The difference between my case and the test case is that my example didn't have const [selection, setSelection] = useState({ start: 0, end: 0 });
<TextInput
onSelectionChange={event => {
console.log(event.nativeEvent.selection);
setSelection(event.nativeEvent.selection);
}}
selection={selection} // if I omit this I get no onSelectionChange callback in canary
} /> |
Sorry for reporting multiple issues at last minute. I found another issue that can affect UX. When there is some text selected anywhere in a page, TouchableOpacity onPress is not called at all. Also, tapping on TouchableOpacity doesn't de-select the text selection so if a user selects some text and scrolls down and tries to tap the button, the user won't know why button press doesn't work. Google Chrome Version 81.0.4044.138 (Official Build) (64-bit) on MacOS. This issue isn't reproducible on Safari (Version 13.0.5 (15608.5.11)) on MacOS. |
Thank.s This is because |
Actually, I think it's a little unusual that text selection affects onPress. Pressable doesn't have In this case https://codesandbox.io/s/intelligent-wilson-cge2o?file=/src/App.js |
@javascripter All those issues should be fixed in |
As a heads up, Twitter hasn't gotten a chance to test this or do the 0.12.0 upgrade yet. Sorry we haven't been able to contribute testing yet :( I'm will try and push some momentum on this. |
@comp615 Let me know if you need any help when updating to 0.12 |
Thanks! https://codesandbox.io/s/naughty-ptolemy-54s48?file=/package.json |
Try |
It's fixed, thank you! Edit: I noticed another issue. In Japanese, when trying to enter a word composed of kanji/hiragana (sort of like Chinese characters), you first enter hiragana, which is like characters to spell out a word, and you get a list of words that have the same pronunciation. In RNW when entering the composition (selecting a word from the list of words) you get double text. (If you are unfamiliar with IME, this doc explains it in detail).
Environment: Google Chrome Version 81.0.4044.138 (Official Build) (64-bit) on MacOS. FYI, I've been receiving this error from a small percentage of traffic after we upgraded to the next branch. Errors seems to mostly come from iPhone, but I haven't been able to reproduce it on my side yet so it's probably a minor issue. Just letting you know.
|
Edit: Actually, I now think the below setTimoeut doesn't quite solve the problem in a proper way. When composing text, you press Enter to select the word, and you still want to keep typing because pressing Enter while composing text (when a list of words is shown) means you want to finish entering the word, not the whole sentence. TextInput shouldn't be blurred on Enter while composing text, but only when Enter is pressed when composition is not happening. https://reactjs.org/docs/events.html @necolas the above double text input issue disappeared if (shouldBlurOnSubmit && hostRef.current != null) {
// $FlowFixMe
hostRef.current.blur();
} to if (shouldBlurOnSubmit) {
// $FlowFixMe
setTimeout(() => {
if (hostRef.current != null) {
hostRef.current.blur();
}
}, 0)
}
|
@javascripter thanks for the excellent reports, and I appreciate you uncovering these subtle issues that often go overlooked during testing (especially related to localization)! |
Hmmm I don't see what could have changed between 0.11 and 0.12 to cause the double text input issue. It's also hard for me to reproduce without guidance. |
I don't see any obvious reason for the error you're seeing either:
What exactly is "small percentage of traffic"? How small? Are you capture logs for Try |
number of daily avg. errors / daily avg. traffic = about 0.05%
I enabled console.error logging and deployed 0.0.0-c4821103d so I will get back to you once we have some data 😉
Thanks. Both the double-text and blur-while-composition issues are fixed in this version on Google Chrome for Mac, iOS Safari and Firefox for Mac. However, on Safari for Mac (Version 13.1, 15609.1.20.111.8) , the blur-while-composition issue is still present. I'll try investigating this issue once I have some time. |
After some digging, I found this article that explains this problem. https://www.stum.de/2016/06/24/handling-ime-events-in-javascript/ Safari for Mac dispatches With the check of from if (!e.isDefaultPrevented() && e.key === 'Enter' && !e.shiftKey && !e.nativeEvent.isComposing) { to if (!e.isDefaultPrevented() && e.key === 'Enter' && !e.shiftKey && !e.nativeEvent.isComposing && e.keyCode !== 229) {
This example below is a bit contrived but basically, I have a page that has a search input wrapped in TouchableOpacity, and if pressed opens a Modal which has the same TextInput with Cancel Button and other contents. On Modal open, TextInput in the modal gets focus, and on onSubmitEditing, the modal closes and the TextInput on the original page gets focus (done by a modal library I'm currently using, in fact the re-focusing is unnecessary as the original TextInput is not editable). If I press Enter in the TextInput on the modal, I receive the above PressResponder error (tested on Safari for Mac). Below is the code example. |
Thanks for the composition fix. That's also recommended on MDN: https://developer.mozilla.org/en-US/docs/Web/API/Document/keyup_event The PressResponder invariant is caused by a |
Both those issues should be fixed in |
Closing as 0.13 is released |
Uh oh!
There was an error while loading. Please reload this page.
Over the next few months I'll be working through some significant changes to React Native for Web. These changes will be made on the
next
branch. The motivation for these changes is to:unstable-native-dependencies
export, which we'd like to remove from ReactDOM.Hooks rewrite (done)
Rewriting components to use Hooks is a prerequisite for all the other changes. Hooks simplify the implementations of components and offer an opportunity to resolve many existing bugs.
Responder system rewrite (done)
Replacing the Responder Event System with a user-space implementation. See #1568 for more details.
Touchables rewrite (done)
Better integrating the PressResponder with DOM expectations, to improve the UX of Touchables. See #1591 for more details.
Canary releases
Most up-to-date canary is shown below. Please report regressions caused by canary releases. Post a comment below and include the canary version, as well as a codesandbox that reproduces the issue if possible.
0.0.0-d33e107ba
(5 June 2020)hitSlop
prop handling. Let browsers use their own automatic hitslop for touch interactions.TabBarIOS
andTimePickerAndroid
exportsImage
caching, which will be reintroduced before a stable release.onLayout
prop now requires aResizeObserver
polyfill to work, and does not fallback to windowresize
events.data-*
props is no longer supported. UsedataSet
props, e.g.,dataSet={{ 'some-key': 1 }}
.Pressable
View
support foraccessibilityValue
.Image
support for variable resolution images (requires bundler integration).TextInput
support foronContentSizeChange
to allow auto-grow textareas.ref.setNativeProps
.Open canary issues
findNodeHandle
inScrollResponder
PressResponder
.The text was updated successfully, but these errors were encountered: