Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. import React from 'react';
  2. import { StyleSheet, Text, View } from 'react-native';
  3. import { ContextProvider } from 'react-simplified-context'
  4. import Navigator from './Navigator'
  5.  
  6. export default class App extends React.Component {
  7. state = {
  8. article :[{
  9. id:1,
  10. title: '매일을 살아가는 감정에 대해서',
  11. content: '사람의 감정이란 외부에서 오는 것이 아니라, 나로 인해서 생겨나는 것이다.',
  12. date: '2019년 7월 8일'
  13. },{
  14. id:2,
  15. title: '행복해야지',
  16. content: '행복하고 싶다. 살아가는 의미를 찾기위해서, 슬프고 괴로우려 세상에 태어나진 않았을테니..',
  17. cdate: '2019년 7월 8일'
  18. }],
  19.  
  20. render() {
  21. return(
  22. <ContextProvider
  23. articles ={this.state.articles}
  24. remove = {(id, title, content)=>{
  25. this.setState({
  26. articles : this.state.articles.filter((article) => article.id !== id), }, this.save)
  27. }}
  28. create={(title, content)=>{
  29. const now = new Date()
  30. this.setState({
  31. articles :[{
  32. id:this.state.id,
  33. title: title,
  34. content: content,
  35. bookmarked :false,
  36. date :'${now.getFullYear()}년 ${now.getMonth() + 1}월 ${now.getDate()}일'
  37. }].concat(this.state.articles),
  38. id : this.state.id +1,
  39. })
  40. }}
  41. >
  42. <Navigator />
  43. </ContextProvider>
  44. );
  45. }
  46. }
  47.  
  48. const styles = StyleSheet.create ({
  49. container: {
  50. flex: 1,
  51. backgroundColor: '#ffffff',
  52. alignItems: 'center',
  53. justifyContent: 'center',
  54. },
  55. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement