Aaron MGDR

Aug 9, 2019

1 min read

How to set an ID in react-native-web

(in hindsight obvious, while trying not so)

So a few months ago, I wanted to set an `id` on a react-native-web (RNW) View component <View id="newsletter"/> But that doesnt work.

Turns out in order to maintain compatibility with ReactNative, RNW uses `nativeID` This is in the docs, but I somehow missed it, until i found this issue https://github.com/necolas/react-native-web/issues/1116

So to set an ID on a view in react native web, which will be mapped to the elements dom node do this

<View nativeID="some-id" />

docs referencing this are here


Getting Free

Love podcasts or audiobooks? Learn on the go with our new app.