score:32

Accepted answer

its type definition from flow, it means that constant app is of type function and it returns reactnode.

reactnode is one of these types: reactchild | reactfragment | reactportal | boolean | null | undefined

this means the function app can return, any valid jsx (in react native its anything from view, text, .etc), reactfragment, react.portal, boolean, null, undefined

if you are confused about the dollar sign, here is a link with explanation. https://www.saltycrane.com/flow-type-cheat-sheet/latest/

there are separate sections for "private" or "magic" types with a $ in the name. see the note here and comment here. update: some these types are now documented here.

for easy you can think of it as its node from react (think of it as scope/namespace)

score:1

react$node is a type defined in react.js

declare type react$node =
  | null
  | boolean
  | number
  | string
  | react$element<any>
  | react$portal
  | iterable<?react$node>;

score:4

it is also a type of declaration of app component as a function but you can change it to

import react, { component } from 'react';
import { platform, stylesheet, text, view } from 'react-native';

export default class app extends component {
    render() {
        return (
            <view style={styles.container}>
                <text style={styles.instructions}>hello world!</text>
            </view>
        );
    }
}

const styles = stylesheet.create({
    container: {
        flex: 1,
        justifycontent: 'center',
        alignitems: 'center',
        backgroundcolor: '#f5fcff'
    },
    instructions: {
        textalign: 'center',
        color: '#333333',
        marginbottom: 5
    }
});

don't forget to remove statement export default app in the last line.


Related Query

More Query from same tag