Props
-
React props로 내려가지 않는 요소들Computer Science/React 2022. 11. 9. 14:01
https://reactjs.org/warnings/special-props.html Special Props Warning – React A JavaScript library for building user interfaces reactjs.org https://stackoverflow.com/questions/42261505/getting-error-message-li-key-is-not-a-prop Getting error message "li: 'key' is not a prop" I'm working with React (version 15.4.2), and I'm populating a dynamically with query results from my database. I thought t..
-
React navigate를 통해 state 전달하기.Computer Science/React 2022. 8. 17. 01:39
보내는 쪽 import { useNavigate } from 'react-router'; const goToDetail = (s) => { navigate('/detail', {state : {id : s.championInfoList }}); }; navigate에 state로써 객체를 전할해 주면 된다. goToDetail(s)} /> 받는 쪽 import {useLocation} from 'react-router-dom'; const {state} = useLocation(); state.id 로 접근하면 된다.
-
React propsComputer Science/React 2022. 8. 16. 14:28
import Counter from "./Counter" fuction App(){ return ( ) } const Counter = (props) = { console.log(props) } 콘솔에 찍어보면 {initialValue : 5} 라고 전달 된다. 여러개를 보내고 싶다면 를 한다면 {a : 1, b : 2} 가 찍힌다. props를 기본 값을 설정할 수 있다. const Counter = ({ initialValue }) => { Counter.defaultProps = { initialValue : 0, }; } 자식 component를 바로 props로 보내서 적용시켜줄수도 있다. const Container = ({children}) => { return ( {children} ) }..