0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

screensフォルダを作成する

Posted at

Vueでのviewsフォルダのようにscreensフォルダを作成

プロジェクト直下のsrcの中にscreensフォルダを作成する。
このフォルダにはvuejsでのviewsフォルダのような役割のフォルダ。

App.jsxをさらにシンプルにする。

現在App.jsxは下記の通り。

import React from 'react';
import { StyleSheet, View } from 'react-native';

import AppBar from './src/components/AppBar';
import CircleButton from './src/components/CircleButton';
import MemoList from './src/components/MemoList';

// eslint-disable-next-line react/function-component-definition
export default function App() {
  return (
    <View style={styles.container}>
      <AppBar />
      <MemoList />
      <CircleButton>+</CircleButton>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#FCE4EC',
  },
});

これをよりスッキリさせる。

screensフォルダの中にMemoListScreen.jsxファイルを作成する。

App.jsxに記述されていた内容を移植してくる。
MemoListScreen.jsx

import React from 'react';
import { View, StyleSheet } from 'react-native';

import AppBar from '../components/AppBar';
import CircleButton from '../components/CircleButton';
import MemoList from '../components/MemoList';

// eslint-disable-next-line react/function-component-definition
export default function MemoListScreen() {
  return (
    <View style={styles.container}>
      <AppBar />
      <MemoList />
      <CircleButton>+</CircleButton>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#FCE4EC',
  },
});

App.jsxにMemoListScreen.jsxを読み込む

App.jsx

import React from 'react';

import MemoListScreen from './src/screens/MemoListScreen';

// eslint-disable-next-line react/function-component-definition
export default function App() {
  return (
    <MemoListScreen />
  );
}

App.jsxがよりスッキリさせることができた。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?