TIL 210923


今日やったこと


学習反応.


EventListenerイベントリスナー

  • クラス
  •  constructor(props) {
        super(props);
    
        this.state = {};
        this.circle = React.createRef(null);
      }
    
    
      hoverEvent = (e) =>{     // e는 event 객체
        console.log(e.target)  // event 가 발생한 요소가 무엇인지 찾기
        console.log(this.circle.current); // e.target 과 같은 요소인지 확인
    
        // 색깔 바꾸기
        this.circle.current.style.background = 'yellow'
      }
    
      componentDidMount() {
        console.log(this.circle);
        // addEventListener를 사용하려면 이미 DOM 요소가 완성되어 있어야함 (Mount가 끝나 있어야함)
        this.circle.current.addEventListener('mouseover', this.hoverEvent) 
                                // 어떤 이벤트가 발생했을때, 어떤 행동을 할 것인가
      }
      
     componentWillUnmount() {
        // 컴포넌트가 사라지면 이벤트 리스너도 같이 사라지게 설정 (클린업)
        this.circle.current.removeEventListener('mouseover', this.hoverEvent)
      }
  • 関数型
  • const Text = (props) => {
      const text = React.useRef(null);
    
      const hoverEvent = () => {
          text.current.style.background = 'yellow';
      }
    
      // useEffect - 리액트 훅
      React.useEffect(() => {
          text.current.addEventListener('mouseover', hoverEvent);
    
          // 이벤트 리스너 지우기(컴포넌트가 사라지는 위치에서 ->  componentWillUnmount())
          return () => {
              text.current.removeEventListener('mouseover', hoverEvent);
          }
      }, []);
      return <h1 ref={text}>텍스트입니다!</h1>;
    };

    ルーティング


  • 単一ページアプリケーション-htmlページ(SPA)でページを移動します.

  • react-router-domの使用(正式な書類参照)
  • Redux Ridex


  • グローバルデータストア
  • は、完全に独立したリポジトリであり、データを1つの場所に集約し、そこからデータを取得することができます.

  • グローバル・ステータス管理フローの重要な内容
    =>reduceのステータス管理プロセス

  • すべての人がグローバルデータを表示できます
    =>購読

  • 参照/変更可能データ(直接データxを変更し、置換可能データを呼び出す関数)
    =>action dispatch(減速機は店舗のデータを変更します)

  • 変更された値は誰にでも表示されます
    =>お店のデータが変更されたことをお知らせします(コンポーネントは新しいデータを使用してOM+再ロードされます)

  • 道徳用語
  • State-Ridexが所有するデータ
  • 動作-修正
  • ActionCreator-アクションを作成するために作成された関数
  • Reducer-実際にデータを変更した場所(割り当て動作により自動的に実行)
  • Store-reduce(データ、reduce、組み込み関数を含む)
  • dispatch-ショップの組み込み関数(変更を要求)
  • に感銘を与える


    精神が崩壊する.

    明日やること


    学習
  • フィードバック
  • 復習
  • 反応(いいですか…?)