Programming/react.js2019. 1. 28. 18:49


[링크 : https://reactjs.org/tutorial/tutorial.html#setup-for-the-tutorial]

[링크 : https://reactjs.org/docs/create-a-new-react-app.html#create-react-app]

  [링크 : https://github.com/facebook/create-react-app#create-react-app-]

  [링크 : https://github.com/facebook/create-react-app/.../README.md#table-of-contents]



node.js가 깔려있어서 그냥 npx 쳐보니 npx를 설치한다고 시간을 좀 잡아먹고 무언가 뜬다  

C:\Users\User>npx

npx: installed 1 in 5.81s

Path must be a string. Received undefined


ERROR: You must supply a command.


Execute binaries from npm packages.


  npx [options] <command>[@version] [command-arg]...


  npx [options] [-p|--package <package>]... <command> [command-arg]...


  npx [options] -c '<command-string>'


  npx --shell-auto-fallback [shell]



Options:

  --package, -p          Package to be installed.                       [string]

  --cache                Location of the npm cache.                     [string]

  --no-install           Skip installation if a package is missing.    [boolean]

  --userconfig           Path to user npmrc.                            [string]

  --call, -c             Execute string as if inside `npm run-script`.  [string]

  --shell, -s            Shell to execute the command with, if any.

                                                       [string] [default: false]

  --shell-auto-fallback  Generate shell code to use npx as the "command not

                         found" fallback.

                                   [string] [choices: "", "bash", "fish", "zsh"]

  --ignore-existing      Ignores existing binaries in $PATH, or in the local

                         project. This forces npx to do a temporary install and

                         use the latest version.                       [boolean]

  --quiet, -q            Suppress output from npx itself. Subcommands will not

                         be affected.                                  [boolean]

  --npm                  npm binary to use for internal operations.

                                                 [string] [default: "C:\\Program

                             Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js"]

  --node-arg, -n         Extra node argument when calling a node binary.[string]

  --version, -v          Show version number                           [boolean]

  --help, -h             Show help                                     [boolean]


For the full documentation, see the manual page for npx(1).



실수로 오타를 냈는데 myapp 이라는 폴더에 기본 템플릿을 생성하도록 명령어를 실행

그나저나 패키지 받는데 무진장 오래걸리네..

그리고 react 관련해서 명령어들이 꽤나 여러가지 출력된다.

C:\Users\User\Desktop>npx create-react-app myap

npx: installed 1 in 2.423s

Path must be a string. Received undefined

npx: installed 63 in 11.172s

C:\Users\User\AppData\Roaming\npm-cache\_npx\10196\node_modules\create-react-app\index.js


Creating a new React app in C:\Users\User\Desktop\myap.


Installing packages. This might take a couple of minutes.

Installing react, react-dom, and react-scripts...


+ react-dom@16.7.0

+ react@16.7.0

+ react-scripts@2.1.3

added 1926 packages in 197.071s


Initialized a git repository.


Success! Created myap at C:\Users\User\Desktop\myap

Inside that directory, you can run several commands:


  npm start

    Starts the development server.


  npm run build

    Bundles the app into static files for production.


  npm test

    Starts the test runner.


  npm run eject

    Removes this tool and copies build dependencies, configuration files

    and scripts into the app directory. If you do this, you can’t go back!


We suggest that you begin by typing:


  cd myap

  npm start


Happy hacking!

 

[링크 : https://reactjs.org/docs/hello-world.html]



+

2019.01.29


node.js 보다 확실히 구동이 좀 오래걸리네..

그리고 자동으로 등록된 브라우저를 실행해서 띄우는데 이거 끄는 법 없나?

(IE edge를 기본으로 하고 크롬써서..)

D:\work\src\myapp>npm start


> myapp@0.1.0 start D:\work\src\myapp

> react-scripts start

Starting the development server...

Compiled successfully!


You can now view myapp in the browser.


  Local:            http://localhost:3000/

  On Your Network:  http://10.0.0.4:3000/


Note that the development build is not optimized.

To create a production build, use npm run build. 


npm run build로 빌드!

D:\work\src\myapp>npm run build


> myapp@0.1.0 build D:\work\src\myapp

> react-scripts build


Creating an optimized production build...

Compiled successfully.


File sizes after gzip:


  34.71 KB  build\static\js\1.fa92c112.chunk.js

  763 B     build\static\js\runtime~main.229c360f.js

  716 B     build\static\js\main.690c38a1.chunk.js

  512 B     build\static\css\main.659f8df7.chunk.css


The project was built assuming it is hosted at the server root.

You can control this with the homepage field in your package.json.

For example, add this to build it for GitHub Pages:


  "homepage" : "http://myname.github.io/myapp",


The build folder is ready to be deployed.

You may serve it with a static server:


  npm install -g serve

  serve -s build


Find out more about deployment here:


  http://bit.ly/CRA-deploy


npm start로는 개발버전으로 실행되고

serve를 통해서 build 디렉토리 내의 것을 실행해야 static하게 구동이 되는 듯?

그리고 포트가 3000 번에서 5000 번으로 바뀐다.

D:\work\src\myapp>npm install -g serve

C:\Users\user\AppData\Roaming\npm\serve -> C:\Users\user\AppData\Roaming\npm\node_modules\serve\bin\serve.js

+ serve@10.1.1

added 78 packages in 3.909s


D:\work\src\myapp>serve -s build


   ┌───────────────────────────────────────────────┐

   │                                               │

   │   Serving!                                    │

   │                                               │

   │   - Local:            http://localhost:5000   │

   │   - On Your Network:  http://10.0.0.4:5000    │

   │                                               │

   │   Copied local address to clipboard!          │

   │                                               │

   └───────────────────────────────────────────────┘ 


+

윈도우에서는 아래와 같이 set을 통해서 한번 해주면 해당 콘솔창에서는 계속 적용 된다.

D:\work\src\myapp> set BROWSER=none 

D:\work\src\myapp> npm start 


[링크 : https://github.com/facebook/create-react-app/issues/2084]

[링크 : https://stackoverflow.com/questions/51706882/how-do-i-npm-start-with-a-specific-browser]

[링크 : https://github.com/kitze/custom-react-scripts/tree/master/packages/react-scripts#others]

  [링크 : https://github.com/facebook/create-react-app/issues/873]

'Programming > react.js' 카테고리의 다른 글

react import {}  (0) 2019.01.31
react html to jsx  (0) 2019.01.29
webpack react  (0) 2019.01.28
react.js + spring  (2) 2019.01.28
react.js  (2) 2019.01.10
Posted by 구차니
Programming/react.js2019. 1. 28. 10:40

으으으 공부해야 할 것..

회사에서 프로젝트를 angular에서 react로 전환할 거라.. ㅠㅠ


[링크 : https://start.goodtime.co.kr/2018/09/스프링-부트-리액트-개발-셋업-2018/]

'Programming > react.js' 카테고리의 다른 글

react import {}  (0) 2019.01.31
react html to jsx  (0) 2019.01.29
webpack react  (0) 2019.01.28
react.js tutorial  (0) 2019.01.28
react.js  (2) 2019.01.10
Posted by 구차니
Programming/android2019. 1. 25. 19:12

안드로이드에서 백그라운드로 주기적인 작업(예를 들면 값을 확인한다거나)하는 법 찾는중

생각해보니.. 포그라운드 앱과 백그라운드 앱으로 나눠지고

각각에 대해서 백그라운드 작업 등록하는 법을 찾아 봐야 할 듯?


[링크 : https://leewon.tistory.com/m/15?category=223806]

[링크 : https://medium.com/til-kotlin-ko/android-o에서의-백그라운드-처리를-위한-jobintentservice-250af2f7783c]

Posted by 구차니
Programming/android2019. 1. 25. 18:55

안드로이드 앱 구성이라고 해야하나

핵심 키워드 중에 하나인데 언제 보냐 ㅠㅠ


[링크 : https://whatisthenext.tistory.com/64]

[링크 : https://recipes4dev.tistory.com/67]

Posted by 구차니
Programming/android2019. 1. 24. 15:33

클릭하면 새로운 창으로 전환하는걸 액티비티 전환이라고 하는 듯

(일단 새로 생성된 창도 MainActivity로 뜨니까 머..)


[링크 : https://medium.com/.../android-개발-8-intent를-사용하여-액티비티-전환하기-4d8b64078427]

[링크 : https://bitsoul.tistory.com/6]

[링크 : https://coding-factory.tistory.com/203]

[링크 : https://philip1994.tistory.com/22]

Posted by 구차니
Programming/android2019. 1. 24. 15:28

비쥬얼 스튜디오 처럼 더블클릭하면 자동으로 메소드 추가되는 식의 자동화 까진 안된건가...

액티비티 에디터에서 onClick 에 함수 이름 넣은 다음

MainActivity.java 에서 해당 메소드를 추가해주면 끝


Toast 라는 신기한(?) 클래스가 나오네..


public void onClick_button1(View v)
{
Toast.makeText(getApplicationContext(), "버튼을 눌렸지비", Toast.LENGTH_LONG).show();

} 

[링크 : https://blog.naver.com/rkdwnsdud555/220284885555]

Posted by 구차니
Programming/android2019. 1. 24. 14:17

에디터에서 apptheme 바꾸어주면 자동으로 res/values/styles.xml이 갱신되는 줄 알았는데 안바뀌네..

버그인지 내가 모르는 단계가 누락된건진 좀 더 봐야겠다.


[링크 : https://itpangpang.xyz/193]

[링크 : https://ertos12.wordpress.com/2013/11/12/android-app에서-app-title-제거-또는-숨기기/]


[링크 : https://stackoverflow.com/questions/18195807/android-studio-rendering-problems]

[링크 : https://stackoverflow.com/questions/21762203/change-the-project-theme-in-android-studio]


+

안드로이드 스튜디오의 액티비티 디자인에서 변경하면 먼가 될줄 알았는데 그걸 연결하는 방법을 잘 못 찾겠다..

수작업으로 styles.xml을 바꾸어 주어야 하는건가...

[링크 : https://stackoverflow.com/questions/22722745/android-studio-themes-dont-work-in-app]

[링크 : https://stackoverflow.com/questions/29673301/android-studio-material-design-styles-xml]

[링크 : https://stackoverflow.com/questions/37944154/generate-style-from-xml-in-intellij-android-studio]

[링크 : https://stackoverflow.com/questions/28465064/creating-styles-v21-xml]


[링크 : https://developer.android.com/guide/topics/ui/look-and-feel/themes]

[링크 : https://developer.android.com/guide/topics/ui/themes]


+

styles.xml 리팩토링 예제

[링크 : https://academy.realm.io/kr/posts/android-resources-refactoring/]

Posted by 구차니
Programming/android2019. 1. 24. 14:15

클릭질(?) 하다가 발견

디자인에서 현재 방향을 고를수 있는데

가장 아래 보면 "Create Landscape Variation" 으로 하면 생성이 가능

다만.. 생성했다가 삭제시에는 아직까지 프로젝트 이해부족으로 원복을 못하고

프로젝트 새로 생성해야 해서... 좀 더 구조를 파악해야 가능할 듯...



Posted by 구차니
Programming/android2019. 1. 24. 13:24

R은 나중에 찾아 봐야겠지만.. 

Resource의 R로 리소스 관리를 위한 객체로 추정된다.

그런 이유로 폴더 깊이에 제한을 두지 않았나 싶은데

폴더 / 파일 구조를 . 으로 연결해서 간접적으로 연결해주는 듯


만약 "img_01.png"이라는 파일을 추가한다면, 리소스 XML에서는 "@drawable/img_01", 자바 코드에서는 "R.drawable.img_01"로 참조되는 것이죠. 

[링크 : https://recipes4dev.tistory.com/91]


이미지 추가방법

[링크 : https://mainia.tistory.com/5727]


하위 디렉토리 지원을 하지 않는다고.

아니요, 안드로이드 자원 메커니즘은 drawable 디렉토리의 하위 폴더를 지원하지 않으므로 넣을 수 없습니다.


res/drawable 폴더 안에있는 항목이있는 하위 폴더를 사용하면 리소스 컴파일러가 실패하게되어 R.java 파일이 올바르게 생성되지 않습니다.


단 한가지는 이미지를 평면 이름 (예 : drawable_actions_sports_soccer.png)에 넣습니다. 

[링크 : https://stackoverrun.com/ko/q/2352287]


[링크 : http://sunphiz.me/wp/archives/1608]


그나저나 제약사항이 은근 많네..

파일명이 한글이 들어가면 안되는구나...

(refactoring으로 변경하면 간단하긴 하지만.. 여러개면 노답이네?)


대문자도 안되고, 숫자 소문자 언더바만 되냐!!!!

res\drawable\TEST_IMAGE2.jpg: Error: 'T' is not a valid file-based resource name character: File-based resource names must contain only lowercase a-z, 0-9, or underscore 


Posted by 구차니
Programming/android2019. 1. 24. 12:37



[링크 : https://hashcode.co.kr/questions/44/px-dp-dip-sp의-차이점이-뭔가요]

[링크 : http://blog.rightbrain.co.kr/?p=1036]

[링크 : https://en.wikipedia.org/wiki/Device-independent_pixel]

Posted by 구차니