1 Matching Annotations
  1. Mar 2021
    1. First of all, I would say it is not good to use margin on the component’s top-level, because it breaks the isolation of components.// A React component with margin set on top-levelconst MyComponent = () => { return <div style="margin: 1rem">...</div>;};margin here is not just affecting the component itself, but also affecting other components (e.g., it is pushing off another component / element sitting next to it)If we want to place this component in a different context or layout, margin would get in the way of resuse


      • コンポーネント外の他のコンポーネントに影響を与えてしまう。(例えば、位置を変えてしまうなどの副作用)
      • 他のレイアウトやコンテキストでコンポーネントを再利用しづらくなってしまう