Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- import { StyleSheet, Text, View } from 'react-native';
- import { ContextProvider } from 'react-simplified-context'
- import Navigator from './Navigator'
- export default class App extends React.Component {
- state = {
- article :[{
- id:1,
- title: '매일을 살아가는 감정에 대해서',
- content: '사람의 감정이란 외부에서 오는 것이 아니라, 나로 인해서 생겨나는 것이다.',
- date: '2019년 7월 8일'
- },{
- id:2,
- title: '행복해야지',
- content: '행복하고 싶다. 살아가는 의미를 찾기위해서, 슬프고 괴로우려 세상에 태어나진 않았을테니..',
- cdate: '2019년 7월 8일'
- }],
- render() {
- return(
- <ContextProvider
- articles ={this.state.articles}
- remove = {(id, title, content)=>{
- this.setState({
- articles : this.state.articles.filter((article) => article.id !== id), }, this.save)
- }}
- create={(title, content)=>{
- const now = new Date()
- this.setState({
- articles :[{
- id:this.state.id,
- title: title,
- content: content,
- bookmarked :false,
- date :'${now.getFullYear()}년 ${now.getMonth() + 1}월 ${now.getDate()}일'
- }].concat(this.state.articles),
- id : this.state.id +1,
- })
- }}
- >
- <Navigator />
- </ContextProvider>
- );
- }
- }
- const styles = StyleSheet.create ({
- container: {
- flex: 1,
- backgroundColor: '#ffffff',
- alignItems: 'center',
- justifyContent: 'center',
- },
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement