cristodagama cristodagama - 19 days ago 7
React JSX Question

How could I trigger a non-event function on a view component in React Native?

I have a function called

getAppVersion()
that handles the display of the version of the react native app I'm working on (new to react native ecosystem).

I wish to display this information in the render f(x) of my class below:

class Splash extends React.Component


How would I go about doing this? I'm thinking something along these lines:

render() {
const version = {
getAppVersion()
};
return (
<View {version} />
);


But I'm clearly missing something.

Answer

Assuming that getAppVersion() is defined, you need to expand the <View> tag. Such that your render() method would look like this:

render() {
  const version = {
    getAppVersion()
  };

  return (
    <View>
      {children}
    </View>
  );
}