Open masakudamatsu opened 4 years ago
To forward ref
to a child component, we need
React.forwardRef()
https://reactjs.org/docs/react-api.html#reactforwardrefuseImperativeHandle()
https://reactjs.org/docs/hooks-reference.html#useimperativehandlewhich will make the code complicated. In these cases, we keep using getElementById()
.
getElementById()
is that it causes multiple elements with the same id
when the same component is reused many times. Now I know how to use React.forwardRef()
and useImperativeHandle
. So we will refactor getElementById()
.
Done for the x-height value box.
For the modular scale boxes, we cannot use forwardRef
because we have two components to refer to.
Instead we will change the composition:
ModularScaleInput
components In ModularScaleBoxes.js
and paste them as attribute values for ModularScaleBoxes
in ModularScale.js
. React.useRef
.
Read https://reactjs.org/docs/refs-and-the-dom.html carefully