How to set an ID in react-native-web

Aaron MGDR
1 min readAug 9, 2019

(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

https://necolas.github.io/react-native-web/storybook/?selectedKind=Components&selectedStory=View&full=0&addons=0&stories=1&panelRight=0

--

--