react에서 inline style로 !important 스타일을 적용시 적용되지않음ex) npm install react-with-important-style위 명령어로 설치 import withImportantStyle from 'react-with-important-style';import 후에 Input = withImportantStyle('input');위처럼 사용을하면 input 컴포넌트가 만들어짐 위와 같이 사용하면 정상동작
onDrop = e => {console.log("#@$#@$");e.preventDefault();e.stopPropagation();} 위 코드처럼 할시 drop이 작동되지않음 onDrop = e => {e.preventDefault();e.stopPropagation();console.log("#@$#@$");} 위 코드처럼해야 drop이 동작됨아마 drop실행하는 이벤트를 막아주지않으니까 drop이 적용되지않는듯drop되자마자 바로 막아줘야 정상적으로 drop이 동작하는듯하다
componentDidMount() { document.addEventListener('click', this.handleClickOutside, true); } componentWillUnmount() { document.removeEventListener('click', this.handleClickOutside, true); } handleClickOutside = event => { const domNode = ReactDOM.findDOMNode(this); if (!domNode || !domNode.contains(event.target)) { this.setState({ visible: false }); } } 위 코드를 이용하면 가능state visible을 이용
useState기본 Hooks함수형 컴포넌트에서 state를 사용할수있도록 해줌123456789101112131415import React, { useState } from 'react'; const Counter = () => { const [value, setValue] = useState(0); return ( 현재 카운터 값은 {value} setValue(value + 1)}>+1 setValue(value - 1)}>-1 )}Colored by Color Scriptercs 1const [value, setValue] = useState(0);cs value : statesetValue : value 값을 변경할 state 함수useState(value의 초기값을 넣음);useState는 여러..