Library | Framework22 [React] CORS 문제 해결 1. 백엔드한테 해결해달라 하기 2. 프론트 안에서 해결하기 -> webpack.config.ts에서 proxy를 설정해준다. devServer: { historyApiFallback: true, port: 3090, devMiddleware: { publicPath: '/dist/' }, static: { directory: path.resolve(__dirname) }, proxy: { '/api/' : { // 프론트에서 api로 보내는 요청은 주소를 3095로 바꿔서 보냄 target: 'http://localhost:3095', changeOrigin:true, } } }, 프론트엔드에서 api로 보내는 요청은 주소를 3095로 바꿔서 보내겠다는 뜻이다 -> http://localhost:309.. 2022. 5. 27. [React] forceUpdate(), PureComponent, shllow-equal, hook(useState, useEffect), map(), reactstrap forceUpdate() constructor(props) { super(props); this.state = { StateString:'react', } } StateChange = () => { this.state.StateString="리액트"; this.forceUpdate(); } render() { return ( this.StateChange('direct', e)}>direct {this.state.StateString} ) } -> this.state.StateString='리액트'와 같이 직접 state를 변경하면 render() 함수를 호출하지 않으므로 화면의 state 값은 바뀌기 전 상태로 남아있다. 이때 forceUpdate() 함수로 화면을 새로고침하면 render() 함수를 .. 2022. 2. 16. 이전 1 2 3 4 5 ··· 11 다음