Skip to content

Enhance component export statement #511

@JayashTripathy

Description

@JayashTripathy

Right now component exports are something like this

import { View } from '@rn-primitives/slot';
import { Stack } from 'expo-router';

import { Container } from '~/components/Container';
import { Text } from '~/components/nativewindui/Text';
import { ScreenContent } from '~/components/ScreenContent';

export default function Home() {
  return (
    <>
      <Stack.Screen options={{ title: 'Tab Two' }} />
      <Container>
        <View className="flex-1 items-center justify-center bg-green-400">
          <Text>Tab Two</Text>
        </View>
      </Container>
    </>
  );
}

Because we are exporting inline. App goes back to the initial screen when using fast refresh
reason you can see this in thread expo/router#455

So if we could make the export defination like this. Then it would not go to the initial screen after every fast refresh

import { View } from '@rn-primitives/slot';
import { Stack } from 'expo-router';

import { Container } from '~/components/Container';
import { Text } from '~/components/nativewindui/Text';
import { ScreenContent } from '~/components/ScreenContent';

function Home() {
  return (
    <>
      <Stack.Screen options={{ title: 'Tab Two' }} />
      <Container>
        <View className="flex-1 items-center justify-center bg-green-400">
          <Text>Tab Two</Text>
        </View>
      </Container>
    </>
  );
}

export default Home;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions