무료
다른 수강생들이 자주 물어보는 질문이 궁금하신가요?
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
React re-rendering 관련 질문
안녕하세요! 양질의 강의 감사드립니다. 구현 중 해결되지 않는 부분이 있어 질문 올립니다. 사용자가 의도한 움직임만 하면 좋겠지만, 간혹 직접 URL을 입력하는 경우에 대해 고민하고 있습니다. 여기에서 발생한 한가지 문제가 있습니다. 만약 사용자가 게시글을 조회하고자할 때 정상적으로 조회하는 것이 아닌, URL을 통해 게시글의 id를 직접 접근하는 경우를 생각했습니다. 그런데 만약 해당 id가 DB에 없을 때가 있을 수 있고, 이것이 문제가 될 것입니다. 이 때 브라우저에 alert를 발생시키고 Redirect 시키도록 만들어보았습니다. 그런데 이 때 정상적인 게시글도 접속시 alert가 발생하는 것을 발견했습니다. 확인해보니, 서버의 payload값이 클라이언트의 status를 업데이트하기전에 이미 리액트가 초기렌더링을 마쳐두어 기본값으로 설정해뒀던 false 값으로 인해 정상적인 글도 alert가 발생하는 것을 확인했습니다. 물론 false일 때 텅 빈 <div>를 렌더링시킨 뒤, 리렌더링되는 것을 기다려도 되겠지만 리액트가 setState를 마치고나서 렌더링하는 동기적인 방법이 있을까요? 위 이미지에서 보시는 것처럼 false는 서버로부터 payload값을 받아와 저장하는 ServerRes status의 기본값이고, 여러번 false로 렌더링되다가 서버에서 보내준 payload 값을 ServerRes에 업데이트하여 유도된 페이지가 렌더링되는 것을 확인할 수 있었습니다. 아직 react-hook이 익숙하지 않아 발생하는 문제인 것 같습니다 ㅠ.ㅠ. 감사합니다.
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
git hub 관련 문의
안녕하세요 선생님. 덕분에 너무 좋은 강의 듣고 있습니다. 감사합니다. 강의 마지막에 git push origin master를 통해 git hub에 파일들을 올리고 나서 git hub에 들어가보면 다 업데이트가 되어있는데요. 궁금한게 여기서 models 파일은 다른 파일들과 달리 업데이트되어있지 않습니다. 어떤 이유 때문에 mdoels만 업데이트가 되지 않는 것인지 궁금합니다. 감사합니다^^
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
import Reducer from './_reducers'; 에서 Reducer가 뭔가요?
_reducers/index.js 의 파일을 보면 Reducer라고 명시된 변수가 없고 rootReducer라는 변수만 있는 것 같은데 이 상태에서 Reducer를 import하는 건 어떤 값을 불러오는 건지 모르겠습니다
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
export 관련 문의
안녕하세요 선생님! 강의 완강하고 재수강하면서 다시 복습 중인데 질문이 있습니다. module.exports로 export 하는 것과 page에서 하듯이 export default 이런식으로 하는 것의 차이가 무엇인지요?
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
withRouter 기능이 무엇인가요?
안녕하세요 좋은 강의 잘 듣고 있습니다. 다름이 아니라, 로그인을 성공적으로 진행한 후 '/' 라우터로 (home으로) 리다이렉트할 때 Unhandled Rejection (TypeError): Cannot read property 'push' of undefined 위 에러가 떠서 찾아보니 withRouter로 감싸주어 처리해주면 위 에러가 사라지더라구요. react-router-dom의 withRouter를 찾아보니 컴포넌트에서 다른 컴포넌트를 사용할 때 쓴다고 하던데, 그럼 export default RegisterPage랑 export defalut withRouter(RegisterPage)랑 큰 차이가 없지 않나 싶은데, 에러가 사라지는게 신기합니다. withRouter로 발생하는 차이가 따로 있을까요? 감사합니다.
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
index.html , index.js 가 어떻게 연결되어 있나요?
각각의 파일을 보는데, index.html 에서 src/index.js를 링크하는 내용이 없는 것 같습니다. 그러면 index.js에서 getElementById를 써서 root태그를 잡는 게 안되지 않나요?
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
08:02 SSH 키 접근이 안되면
window기준으로 git bash로 여시고 cat ~/.ssh/id_rsa.pub 해보시면 나옵니다!
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
npm run start 실행시 에러가 뜹니다
package.json 파일입니다! { "name": "nodejs_study", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "start": "node index.js", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "jung", "license": "ISC", "dependencies": { "express": "^4.17.1" } } 에러 메세지입니다. 이렇게 에러가 떠서 실행이 안되는데, 같은 문제를 겪고 계신 분들이 계신 것 같아서 확인 부탁드립니다. 좋은 강의 감사합니다 :)
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
AuthenticationCheck의 props
좋은 강의 무료로 제공해주셔서 감사합니다!!! auth.js에서 AuthenticationCheck(props) function 안에서 props.history.push를 쓰시는데 props가 어디에서 넘어왔다고 이해하면 될까요? 그리고 각 케이스마다 history.push를 통해 다른 페이지로 이동시켜주는데 return <SpecificComponent />의 역할이 잘 이해가 안갑니다. HOC 문법인지 다른 의도가 있는건지 궁금합니다!
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
{ User } 에 중괄호를 넣는 것의 의미
User 자바스크립트 파일을 가져올 때 다음과 같이 중괄호를 넣어서 하는데 그것의 의미는 무엇인가요? const { User } = require("./models/User");
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
몽고 cluster 못찾으시는 분들
강의에는 안나오지만 일단 프로젝트를 하나 만들고 Build a Database 누르면 0:56과 같은화면 나옵니다!
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
포스트맨에서 Success 나오는데 서버로가면 값이 안나와요ㅠ
포스트맨에서 값을 전송했는데 서버에가면 값들을 제대로 못받아오는데 무엇이 잘못되었을까요..ㅠ //index.js const express = require('express') const app = express() const port = 5000 const bodyParser = require('body-parser'); const config = require('./config/key'); const { User } = require("./models/User"); //application/x-www-form-urlencoded app.use(express.urlencoded({extended: true})); //application/json app.use(express.json()); const mongoose = require('mongoose') mongoose.connect(config.mongoURI,{ useNewUrlParser: true,useUnifiedTopology:true,useCreateIndex:true,useFindAndModify:false }).then(() =>console.log('MongoDB Connected...')) .catch(err =>console.log(err)) app.get('/', (req, res) => res.send('Hello SOSO!!!!!!!!!!!!!!!~~')) app.post('/register',(req,res) => { //회원가입할때 필요한 정보들을 client에서 가져오면 // 그것들을 데이터베이스에 넣어준다. const user = new User(req.body) user.save((err, userInfo) =>{ if(err) return res.json({success: false,err}) return res.status(200).json({ success: true }) }) }) app.listen(port, () => console.log(`Example app listening at http://localhost:${port}!`)) //User.js const mongoose = require('mongoose'); const bcrypt = require('bcrypt'); const saltRounds = 10; const userSchema = mongoose.Schema({ name: { type: String, maxlength:50 }, email: { type: String, trim:true, unique:1 }, password:{ type: String, minlength: 5 }, lastname:{ type:String, maxlength:50 }, role: { type:Number, default:0 }, image:String, token: { type:String }, tokenExp: { type:Number } }) userSchema.pre('save',function( next ){ var user = this; if(user.isModified('password')){ //비밀번호 암호화시킨다. bcrypt.genSalt(saltRounds, function(err, salt) { if(err) return next(err); bcrypt.hash(user.password, salt, function(err, hash){ if(err) return next(err); user.password = hash; next(); }) }) } else{ next(); } }) const User = mongoose.model('User',userSchema) module.exports = { User } req.body 찍어보면 빈객체로 나와요
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
안녕하세요. 프론트에서 로그인이 안됩니다.
제 생각은 proxy setup이 조금 이상한거 같은데 혹시 아시는 분 계실까요?git: https://github.com/alsemffp82/boiler-plate/tree/master
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
POSTMAN 오류입니다 ㅠㅠ
계속 이렇게 뜨네요 ㅠㅠ 무슨 문제일까요...? https://github.com/maruihitoha/boilerPlate_tutorial 입니다..
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
postman 오류
강의와 모든부분 동일하게 작성했고 postman 에서 send 클릭시에 계속해서 오류가 발생하는데 어떤부분이 문제인지 모르겠습니다 ㅠㅠ GITHUB 주소 첨부합니다 ( React-Node ) 폴더 https://github.com/OHYUNBEOM index.js User.js postman 오류 visual studio code 오류
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
postman 오류(Cannot POST /register)
postman에서 send를 누루면 Cannot POST /register << 이런 에러가 나와요 const express = require('express') //express module을 가져와라 const app = express() //express() function 을 이용해서 express app 을 만듬 const port = 5100 const mongoose = require('mongoose') const bodyParser = require('body-parser'); const {User} = require("./models/User"); app.use(bodyParser.urlencoded({extended:true})); app.use(bodyParser.json()); mongoose.connect('mongodb+srv://000000@0000000.7lopm.mongodb.net/myFirstDatabase?retryWrites=true&w=majority', { useNewUrlParser : true, useUnifiedTopology : true, useCreateIndex : true, useFindAndModify : false }).then(()=> console.log('MongoDB Connected..')).catch(err => console.log(err)) app.get('/', (req, res) => { res.send('Hello World!') })app.post('/register', (req, res) => { const user = new User(req.body); user.save((err, userInfo) => { if(err) return res.json({success : false, err}) return res.status(200).json({ success : true }) }) })
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
좋은 자료로 잊고가는 기초들도 다시 공부할 수 있어 정말 감사합니다.
혹시나 가능 하시다면, Typescript로 리액트와 express 강의 같은 내용을 해주실 수 없으실까요? 유료라도 결제해서 꼭 보고 싶습니다.
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
postman에서 logout success는 나오는데 DB에서 token은 안 지워져요
postman에서 log out을 하면 success message는 뜨는데 DB의 token은 안지워지는데 따라히면서 같은 오류를 겪으신 분 혹시 계신가요?
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
db connectio 에러
DB 연결에서 계속 오류가 나요 에러 메시지 보고 cmd 창에서 ip 보고 mongoDB network access 에서 ip 수정하고 다시 이전꺼랑 해서 새로 추가했는데 동일하게 오류가 나와요 확인 부탁드립니다 ㅜㅜ PS D:\nodeJs\models> npm run start > nodejs@1.0.0 start D:\nodeJs > node index.js Example app listening at http://localhost:5100 MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/ at NativeConnection.Connection.openUri (D:\nodeJs\node_modules\mongoose\lib\connection.js:846:32) at D:\nodeJs\node_modules\mongoose\lib\index.js:351:10 at D:\nodeJs\node_modules\mongoose\lib\helpers\promiseOrCallback.js:32:5 at new Promise (<anonymous>) at promiseOrCallback (D:\nodeJs\node_modules\mongoose\lib\helpers\promiseOrCallback.js:31:10) at Mongoose._promiseOrCallback (D:\nodeJs\node_modules\mongoose\lib\index.js:1149:10) at Mongoose.connect (D:\nodeJs\node_modules\mongoose\lib\index.js:350:20) at Object.<anonymous> (D:\nodeJs\index.js:14:10) at Module._compile (internal/modules/cjs/loader.js:1251:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10) at Module.load (internal/modules/cjs/loader.js:1100:32) at Function.Module._load (internal/modules/cjs/loader.js:962:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) at internal/main/run_main_module.js:17:47 { reason: TopologyDescription { type: 'ReplicaSetNoPrimary', setName: null, maxSetVersion: null, maxElectionId: null, servers: Map(3) { 'wwwpyk-shard-00-01.7lopm.mongodb.net:27017' => [ServerDescription], 'wwwpyk-shard-00-02.7lopm.mongodb.net:27017' => [ServerDescription], 'wwwpyk-shard-00-00.7lopm.mongodb.net:27017' => [ServerDescription] }, stale: false, compatible: true, compatibilityError: null, logicalSessionTimeoutMinutes: null, heartbeatFrequencyMS: 10000, localThresholdMS: 15, commonWireVersion: null } }
- 미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
heroku 배포에 대하여
안녕하세요. 헤로쿠 배포해서 url 까지 받았는데요 url을 열면 localhost:5000번 즉, client 화면이 안나오고 server쪽에서 열리더라고요... 어떻게 해야 할까요??