이런... string 안에서 ${변수}를 사용하려면 '가 아니라 `를 사용해야한다. 세미콜론(;)급 통수다 ㅠㅠ
'
- Single Quote
- 세미콜론의 오른쪽에 있은
- " (Double Qutoe)와 함께 string을 표현할 때 사용
`
- Backtick
- 1의 왼쪽, ESC 아래, ~와 함께 있음
- ${변수}를 인식 : string templating에 사용
이전에는 string의 concatenating을 사용해야하냐, templating을 사용해야하냐를 논했지만, 현재는 비슷하다고 판단하는듯 하다. concatenation이 빠르다는 말도, templating이 빠르다는 말도 있다.
참고 내용
[1] https://hello-bryan.tistory.com/120
React `string 안에 ${변수명}` 잘 안될 때
React Variables and String Variables in String format 처음 시작할 때 잘 모를수도 있는 내용이라 적어봅니다. 아래와 같은 코드가 있습니다. render() { const {username} = this.state; return ( mysql conne..
hello-bryan.tistory.com
[2] https://stackoverflow.com/questions/47067319/back-tick-vs-single-quote-in-js
Back-tick vs single quote in js
Working on node.js (server side), I wonder if I should use all back-ticks (`) instead of the regular quotes (" or ') all the time since it will make the code consistent. Is there any specific reaso...
stackoverflow.com
Are ES6 template literals faster than string concatenation?
Does HTML code generation run measurably faster in modern browsers when using string concatenation or template literals in ES6? For example: String concatenation ""+ "<
stackoverflow.com
'프레임워크 > React Native' 카테고리의 다른 글
[React Native] 생명주기와 useEffect() (0) | 2022.03.28 |
---|---|
[ReactNative] FCM+AsyncStorage 설치 후 build failed (0) | 2022.02.18 |
[ReactNative] Windows 프로젝트 생성 및 안드로이드 실행 (0) | 2022.02.07 |
React Native Tutorial (JSX, Component, State, Prop) (0) | 2021.07.09 |
WSL(Windows Subsystem for Linux)에서 React Native 설치 (0) | 2021.06.27 |