Skip to content

yeo11200/jlob

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

18 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

jlob

React ProgressBar

npm run deploy
// ๋ฐฐํฌ ๋ช…๋ ์–ด
// react ํŒจํ‚ค์ง€ ๋‹ค์šด๋กœ๋“œ
npm install -g create-react-app

// react ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ
create-react-app project

// spa๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ์œ„ํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
npm install --save react-router-dom

//git page์— ์˜ฌ๋ฆฌ๊ธฐ ์œ„ํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
npm install --save gh-pages
// url๋งํฌ๋ฅผ ๊ฑฐ๋Š”๋ฐฉ์‹
<Link to="/link">
// url ๋งํฌ๋ฅผ ๊ฑฐ๋Š”๋ฐ ์ •ํ™•ํ•œ ๋งํฌ๊ฐ€์•„๋‹ˆ๋ฉด ์ถœ๋ ฅ๋˜์ง€์•Š๋Š”๋‹ค.
<Link exact to="/link">
// ๋ฐ›์€ url์— ๋”ฐ๋ฅธ component ์ถœ๋ ฅ
<Route path="/link" component={component}>
// ๋ฐ›์€ url์— ๋”ฐ๋ฅธ component ์ถœ๋ ฅ
<Route path="/link" render={() => { <h2>hello</h2>}}>
// as๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋ณ„๋ช…์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.
import { BrowerRouter as Router, Route, Link} from 'react-router-dom'
props์˜ ํƒ€์ž…์„ ์ง€์ •ํ•ด์ค„ ๊ฒฝ์šฐ ์‚ฌ์šฉ์„ ํ•œ๋‹ค.
npm install --save prop-types

or 

yarn add prop-types
// class ๋ช…์œผ๋กœ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ
// ์•„๋ž˜์ฒ˜๋Ÿผ class๋ช… defaultProps๋ฅผ ํ•ด์ค€๋‹ค.
// defaultProps๋Š” props๊ฐ€ ์•ˆ๋„˜์–ด์˜ฌ ๊ฒฝ์šฐ ๊ธฐ๋ณธ์ ์œผ๋กœ ๋‹ด์•„์ฃผ๊ฑฐ๋‚˜ ํƒ€์ž…์„ ์ง€์ •ํ•  ๋•Œ ์‚ฌ์šฉ์„ ํ•œ๋‹ค.
className.defaultProps = {
    propName : propType.string;
}
<!-- classname ์ž‘์„ฑ์‹œ {this.state.a ? 'a' : ''} -->
<li className={this.state.classNamePush == 'zzzz' ? 'on' : ''}>

<!-- ๋‹ค์ค‘ className์„ ์„ค์ •ํ•  ๊ฒฝ์šฐ
  3ํ•ญ์—ฐ์‚ฐ์ž๋กœ ๋‹ค์ด๋‚˜๋ฏนํ•˜๊ฒŒ ํ•˜๋ ค๋ฉด ()์„ ์‚ฌ์šฉ์ด์šฉํ•ด์„œ ์‚ฌ์šฉํ•ด์•ผํ•œ๋‹ค.\
 -->
<div className={"profile-about-me " + (this.state.menuOn === 'info' ? 'on' : '')}>
// React์—์„œ event๋ฅผ ๋ฐœ์ƒํ•  ๊ฒฝ์šฐ
// constructor = this.event.bind๋ฅผ ํ•˜๊ฑฐ๋‚˜
// html์— function ์•ˆ์— event๋ฅผ ๋„ฃ์–ด์ฃผ๋ฉด ๋œ๋‹ค
    menuClickOn = function(menu){
        console.log(menu);
        this.setState({menuOn : menu})
    }

    <ul className="profile-menu">
        <li onClick={ () => { this.menuClickOn('info')}}>์ž๊ธฐ์†Œ๊ฐœ์„œ</li>
        <li onClick={ () => { this.menuClickOn('project')}}>ํ”„๋กœ์ ํŠธ๊ฒฝํ—˜</li>
        <li onClick={ () => { this.menuClickOn('announce')}}>๋ฐœํ‘œ๋‚ด์šฉ</li>
    </ul>
import * as Fun from '../fun';
// ๋ณต์žกํ•œ ๊ณ„์‚ฐ ๊ณต์‹์ด๋‚˜ ์—ฌ๋Ÿฌ ๊ณณ์—์„œ ์‚ฌ์šฉ๋  ํ•จ์ˆ˜๋ฅผ ์ง€์ •ํ•ด์„œ ์‚ฌ์šฉํ•œ๋‹ค.
// *๋Š” export ๋œ ๋ชจ๋“  ๊ฒƒ์„ ๊ฐ€์ง€๊ณ ์˜จ๋‹ค
componentWillMount() // react ์ปดํฌ๋„ŒํŠธ๊ฐ€ ์‹คํ–‰ํ•  ๋•Œ ์ œ์ผ๋จผ์ € ์‹คํ–‰, ์ฃผ๋กœ axios๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ์‚ฌ์šฉ
componentDidUpdate() // status or props ๋ณ€๊ฒฝ๋  ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค.


/** axios๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•
http์˜ ๋ฉ”์†Œ๋“œ๋Š”
get, post, put, delete
Rest API์˜ http ๋ฉ”์†Œ๋“œ๋กœ ์‚ฌ์šฉ
*/

// params๋ฅผ ๋„ฃ์œผ๋ฉด url์— ํŒŒ๋ผ๋ฉ”ํ„ฐ ๋ฐ์ดํ„ฐ๊ฐ€ ๋“ค์–ด๊ฐ„๋‹ค
axios.get('/url', {params : { id : 1}}).then( (response) => {}).catch((e) => {});
axios.post('/url', {a:1, b:2}).then( (response) => {}).catch((e) => {});

or 

axios({
  method: 'get',
  url: '/url',
  responseType: 'stream'
})

axios({
  method: 'post',
  url: '/user/12345',
  data: {
    firstName: 'Fred',
    lastName: 'Flintstone'
  }
});

// axios์˜ parameter์€ url, data(๊ฐ์ฒด), header(๊ฐ์ฒด) ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.
axios.get(url, params, header).then().catch(e) 
1. firebase๋ฅผ ๊ฐ€์ง€๊ณ  ์›น push๋ฅผ ๋งŒ๋“ค ์˜ˆ์ •
npm install --save firebase
import FireBase from 'firebase';

FireBase.initializeApp();

2. summernote ์ž‘์—…์ค‘

npm install --save react-summernote

or 

yarn add react-summernote
// summer note๋Š” jquery ๊ธฐ๋ฐ˜์œผ๋กœ ์ž‘๋™์ด ๋œ๋‹ค
// jquery ํ”Œ๋กœ๊ทธ์ธ ์‚ฌ์šฉ
npm install --save jquery

or 

yarn add jquery


// react์—์„œ string ํ˜•์˜ html์„ html ํŒŒ์ผ๋กœ ๋ณ€ํ˜•์„ ํ•œ๋‹ค
dangerouslySetInnerHTML = { {__html : value}}

3. cors

/**
 * express์—์„œ cors๋ฅผ ํ–ˆ๋Š”๋ฐ๋„ ์—๋Ÿฌ๊ฐ€ ๋‚ฌ๋‹ค
 * ํ™•์ธ์€ ํ•ด๋ณด๋‹ˆ localhost๋ฅผ ์ž‘์„ฑํ•  ๋• http://๋ฅผ ๊ผญ๋ถ™ํ˜€์ค˜์•ผํ•œ๋‹ค
 * ๊ทธ๋ ‡๊ฒŒ cors๋ฅผ ๋ฒ—์–ด๋‚ ์ˆ˜์žˆ๋‹ค.
*/
axios.get('http://localhost:8004/profile', {}).then((response) => {
    console.log(response);
});

4. axios header

// ๊ธ€๋กœ๋ฒŒ๋กœ ์„ ์–ธํ•ด์„œ ์‚ฌ์šฉ์„ ํ•  ์ˆ˜ ์žˆ๋‹ค.
axios.defaults.baseURL = 'https://api.example.com';
axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';

// axios๋ฅผ ์„ ์–ธ
const instance = axios.create({
    // ๊ธฐ๋ณธ๊ฐ’์„ ์„ธํŒ…
    // timeout์„ ๋ณดํ†ต 0์ดˆ๋กœ ์ง€์ •
    baseURL = 'https://api.example.com';
});

// ์ธ์Šคํ„ด์Šค์˜ ๋ชจ๋“  ์š”์ฒญ์€ 2.5์ดˆ ๊ฐ„๋งŒ ๋Œ€๊ธฐ ํ›„ ํƒ€์ž„์•„์›ƒ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค.
instance.defaults.timeout = 2500;

5. React Oh Tag

// https://flamingotiger.github.io/frontend/react/react-helmet/
npm install --save react-helmet @types/react-helmet

1. og tag๋ž€
- ๋ฏธ๋ฆฌ๋ณด๊ธฐ ์ œ๋ชฉ, ์„ค๋ช…, ์ด๋ฏธ์ง€๋กœ ์‚ฌ์ดํŠธ์˜ ์ •์ฑ…์„ ํ•  ์ˆ˜ ์žˆ๊ณ , head์— meta tag์— ์ ์–ด์„œ ์‚ฌ์šฉ์„ํ•œ๋‹ค.
og tag ๋‹ค์–‘ํ•œ ์†์„ฑ
์†์„ฑ ๋œป
subject ํ™ˆํŽ˜์ด์ง€์˜ ์ฃผ์ œ
title ํ™ˆํŽ˜์ด์ง€์˜ ์ด๋ฆ„
description ํ™ˆํŽ˜์ด์ง€์˜ ์„ค๋ช…
Keywords ํ‚ค์›Œ๋“œ๋ฅผ ์ž…๋ ฅ
Author ๋งŒ๋“ค์‚ฌ๋žŒ ์ด๋ฆ„
robots All, index,follow, noindex,follow. index,nofollow, noindex,nofollow
// a tag์—์„œ href๋กœ ๋ฉ”์ผ์„ ๋ณด๋‚ด๋ ค๊ณ  ํ•˜๋ฉด mailto๋ฅผ ์•ž์— ๋ถ™ํ˜€์„œ ์‚ฌ์šฉ์„ ํ•ด์•ผํ•œ๋‹ค.

<a href="mailto:[email protected]">[email protected]</a>

react์—์„œ ํŒŒ๋ผ๋ฉ”ํ„ฐ ์ถ”๊ฐ€ ํ•˜๋Š” ๋ฐฉ๋ฒ•

<Link to={'/profile?:pa&:page&:search'}>
</Link>

<Route path="/profile?:pa&:page&:search" component={Compornt}></Route>

react ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๋ถˆ๋ฆฌ๊ณ  ๋‚˜์„œ import

// React ํ•จ์ˆ˜์•ˆ์— lazyํ•จ์ˆ˜๊ฐ€ ๋ณ„๋„๋กœ ์žˆ๋‹ค. lazy๋ž€ ๋ถˆ๋ฆฌ๊ณ  ๋‚˜์„œ ์‚ฌ์šฉ์„ ํ•˜๋Š” ๊ฒƒ์„ ์ง€์นญํ•˜๋Š”๋ฐ ์ฃผ๋กœ ์ด๋ฏธ์ง€๋ฅผ ๋ถ€๋ฅผ ๋•Œ ์‚ฌ์šฉ์„ ํ•œ๋‹ค

// ๊ทธ๋ž˜์„œ js ํŒŒ์ผ ๊ฐ™์€ ๊ฒฝ์šฐ๋„ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๋ถˆ๋ฆฐํ›„ lazy๋ฅผ ์ฃผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค.

// ex)

React.lazy( () => import aaaa from './route/React');

socal login

/**
 *  kakao login ์ถ”๊ฐ€ 
 **/
npm install react-kakao-login

/**
 * google login ์ถ”๊ฐ€
 * */
npm install react-google-login

/**
 * facebook login 
 * **/
npm install react-facebook-login --save --force

/**
 * naver๋Š” ๋”ฐ๋กœ ์ง€์›์„ ์•ˆํ•ด์ค˜์„œ ์„ ์–ธ์„ ํ•ด์•ผํ•œ๋‹ค.
 * 
 * ์™ธ๋ถ€ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ๋ถˆ๋Ÿฌ๋‚ด๊ธฐ์œ„ํ•œ npm 
 * npm ์— ํŒจํ‚ค์ง€๋ฅผ ์ฐพ์œผ์‹ญ์‹œ์˜ค.
 * ๋‚ด ํ”„๋กœ์ ํŠธ์—์„œ ํŒจํ‚ค์ง€๋ฅผ ๋‹ค์šด๋กœ๋“œํ•˜๊ณ  ์„ค์น˜ํ•˜์‹ญ์‹œ์˜ค (npm install typekit).
 * import ๋‚ด๊ฐ€ ํ•„์š”๋กœํ•˜๋Š” ํŒจํ‚ค์ง€ (import Typekit from 'typekit';)
 * */
<script type="text/javascript" src="[https://static.nid.naver.com/js/naveridlogin_js_sdk_2.0.0.js](https://static.nid.naver.com/js/naveridlogin_js_sdk_2.0.0.js)" charset="utf-8"></script>

ui framework

// with npm
npm install @material-ui/icons // svg ํ˜•์‹์˜ ์•„์ด์ฝ˜ ํ”„๋ ˆ์ž„์›Œํฌ npm

// with npm
npm install @material-ui/core // ui๋ฅผ ๊ทธ๋ฆด์ˆ˜ ์žˆ๋Š” ํ”„๋ ˆ์ž„์›Œํฌ npm

์ ˆ๋Œ€ ๊ฒฝ๋กœ ์„ค์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•

yarn add cross-env

or
npm install cross-env
"start": "cross-env NODE_PATH=src/ react-scripts start",
"build": "cross-env NODE_PATH=src/ react-scripts build",

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published