Slide 17
Slide 17 text
React と Vue で異なるレンダリングの仕組み
コードの見た目ではそこまで差がないが、
「値の変更がどう反映されるか」が違う
import { useState, useEffect } from 'react';
export default function Counter() {
const [count, setCount] = useState(0);
function increment() {
setCount((c) => c + 1);
}
const doubledCount = count * 2;
return (
Count is: {count}
);
}
import { ref, computed } from 'vue'
const count = ref(0)
function increment() {
count.value++
}
const doubledCount = computed(() => count.value * 2)
Count is: {{ count }}
理由1:簡単に高いパフォーマンスを得られる