Web 개발을 하다 Developer Console 에  다음과 같은 정보가 나타났을 때 ...

Chrome Developer Console screenshot

More info 에 표시되어 있는 링크(https://goo.gl/9p2vKq) 로 이동하여 내용을 확인한다.

결국 autocomplete 속성을 설명한 페이지로 이동하게 되는데

이 페이지에서 내용을 확인한다.

 

Autofilling form controls: the autocomplete attribute

https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls%3A-the-autocomplete-attribute

 

하지만 React 개발 시 Attribute 명을 autocomplete 로 입력하게 되면 아래와 같은 Error Message 를 확인하게 된다.

Chrome Developer Console ScreenShot

내용을 확인해 보면 autoComplete 로 입력을 유도하는 Message 를 확인할 수 있다.

 

해당사항을 수정하게되면 Console 에서 Message 가 사라지는 모습을 확인할 수 있다.

 

 

행복한 고수되셔요. ^^

 

woojja ))*

\\\\\\\\\\\\\\\\\\\\\\\\\\\

 

 

 

 

 

 

 

 

반응형

'Web > HTML 5' 카테고리의 다른 글

[HTML Symbols] UTF-8 Dingbats  (0) 2020.02.06
[HTML 5] 20. File API - 동영상  (0) 2011.07.29
[HTML 5] 19. SVG - 동영상  (0) 2011.07.29
[HTML 5] 18. Geolocation API - 동영상  (0) 2011.07.21
[HTML 5] 17. Web Socket - 동영상  (0) 2011.07.21

yarn add react-router-dom

yarn add firebase

yarn add redux redux-logger react-redux  

 

Redux 설정

 

1. redux 를 이용하기 위해 Provider 의 아래에 위치.

// ./index.js

import { Provider } from 'react-redux';

...

ReactDOM.render(
    <Provider>
        <BrowserRouter>
            <App />
        </BrowserRouter>
    </Provider>,
    document.getElementById('root')
);

2. redux Folder 를 생성한다.

3. root.reducer.js 를 생성한다.

 

4. user Folder 를 생성한다.

5. user.reducer.js 를 생성한다.

 

// ./redux/user/user.reducer.js

// default value 를 설정.
const INITIAL_STATE = {
    currentUser: null
}

/*
reducer 에서는 state 와 action 을 parameter 로 사용한다.
state 에는 현재의 state (current state) 를 담고 있다.
action 은 action 의 type 과 값을 담고 있는 payload 를 포함하고 있다.
*/
const userReducer = (state = INITIAL_STATE, action) => {
    switch(action.type) {
        case 'SET_CURRENT_USER':
            return {
                ...state,
                currentUser: action.payload
            }
        default:
            return state;
    }
}

export default userReducer;

6. root.reducer 에 user reducer 를 포함시킨다.

// ./redux/root.reducer.js

import { combineReducers } from 'redux';

import userReducer from './user/user.reducer';

// redux 내의 state 는 하나의 큰 json object 다.
// 생성한 Reducer 를 combineReducers 를 이용하여 관리한다.
export default combineReducers({
    user: userReducer
});

7. store 를 생성하여 reducer 를 담는다.

// ./redux/store.js

import { createStore, applyMiddleware} from 'redux';
// redux code 디버깅시 유용한 middleware
import logger from 'redux-logger'; 

import rootReducer from './root.reducer';

// 사용할 middleware 를 등록
const middlewares = [logger];

// store 생성
const store = createStore(rootReducer, applyMiddleware(...middlewares));

export default store;

8. redux  의 Provider 에 store 정보를 설정한다.

// ./index.js

...

import store from './redux/store';

...

ReactDOM.render(
    <Provider store={store}>
        <BrowserRouter>
            <App />
        </BrowserRouter>
    </Provider>,
    document.getElementById('root')
);

9. 이제 action 을 생성한다.

// ./redux/user/user.action.js

export const setCurrentUser = user => {
    return ({
        type: 'SET_CURRENT_USER',
        payload: user
    });
}

Redux 의 사용.

 

1. Redux 에 연결한다.

 

connect()

 

// ./App.js

...

import { connect } from 'react-redux';

...

// connect(mapStateToProps, mapDispatchToProps)(Component)
// 초기에는 전달할 mapStateToProps state 값이 없으므로 null 을 전달 
export default connect(null, )(App);

2. action 을 Reducer 와 연결할 수 있도록 dispatch 에 action 을 넘겨준다.

// ./App.js

...

import { setCurrentUser } from './redux/user/user.actions';
...


class App extends React.Component {

...

something() {

  setCurrentUser({
    currentUser : {
    id: snapShot.id,
    ...snapShot.data()
    }
  });
}

...

}

const mapDispatchToProps = dispatch => ({
  setCurrentUser: user => dispatch(setCurrentUser(user))
})

//connect(mapStateToProps, mapDispatchToProps)(Component)
export default connect(null, mapDispatchToProps)(App);

 

3. 위 component 를 사용하는 상위 component 의 parameter 를 전달하는 부분을 삭제한다.

// ./App.js

<Header currentUser={this.state.currentUser} />

// =>

<Header />

 

4. 사용할 component 에서 redux 연결하기 위해 react-redux 의 connect 를 추가한다.

// state 를 사용할 component

import { connect } from 'react-redux';

...


const Header = ({ currentUser }) => {
    return (
        ...
    );
}

// 이름은 아무래도 상관없지만 mapStateToProps 이 redux code 표준.
// argument 로 사용되는 state 가 root reducer 의 state 다.
const mapStateToProps = (state) => ({
    currentUser : state.user.currentUser
});

// 처음에는 root reducer 의 user state 가 없으므로 null 일 것이다.
export default connect(mapStateToProps)(Header);

 

 

Site 구축 연습 중에 정리차원의 지극히 개인적인 내용입니다.

 

행복한 고수되셔요.

 

woojja ))*

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

반응형

'Web > React' 카테고리의 다른 글

[Web/React] React info ...  (0) 2020.01.29
[React] npm packages and Database info in blog site  (0) 2019.12.19
[React] React 정리  (0) 2018.02.19

React 로 작업할 때 알아두어야 할 / 알아두면 좋은 사항들에 대한 링크 정리.

 

Google Font :

https://fonts.google.com/

 

node sass :

https://github.com/sass/node-sass

Node-sass is a library that provides binding for Node.js to LibSass, the C version of the popular stylesheet preprocessor, Sass.

It allows you to natively compile .scss files to css at incredible speed and automatically via a connect middleware.

Find it on npm: https://www.npmjs.com/package/node-sass

Follow @nodesass on twitter for release updates: https://twitter.com/nodesass

 

React Route Dom Documentation :

https://reacttraining.com/react-router/web/guides/quick-start

 

HOC (Higher-Order Component)

https://reactjs.org/docs/higher-order-components.html

A higher-order component (HOC) is an advanced technique in React for reusing component logic.

HOCs are not part of the React API, per se. They are a pattern that emerges from React’s compositional nature.

Concretely, a higher-order component is a function that takes a component and returns a new component.

const EnhancedComponent = higherOrderComponent(WrappedComponent);

Whereas a component transforms props into UI, a higher-order component transforms a component into another component.

 

firebase :

https://firebase.google.com/

firebase web documentation :

https://firebase.google.com/docs/reference/js/

firebase npm :

https://www.npmjs.com/package/firebase

npm i firebase

 

imgBB : 이미지 공유 API

https://imgbb.com/

 

Template Literal (Javascript) :

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

 

cubic-bezier : easing-function

https://developer.mozilla.org/en-US/docs/Web/CSS/easing-function

 

 

 

 

 

 

 

 

 

 

 

행복한 고수되셔요...

Woojja ))* 

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

반응형

'Web > React' 카테고리의 다른 글

[React] React for ECommerce Site with Redux 1  (0) 2020.01.30
[React] npm packages and Database info in blog site  (0) 2019.12.19
[React] React 정리  (0) 2018.02.19

+ Recent posts