You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
437 B
17 lines
437 B
import { useEffect, useRef } from 'react';
|
|
import { yuan } from '../components/Charts';
|
|
|
|
/** 减少使用 dangerouslySetInnerHTML */
|
|
const Yuan: React.FC<{ children: string | number }> = ({ children }) => {
|
|
const spanRef = useRef<HTMLSpanElement>(null);
|
|
|
|
useEffect(() => {
|
|
if (spanRef.current) {
|
|
spanRef.current.innerHTML = yuan(children);
|
|
}
|
|
}, [children]);
|
|
|
|
return <span ref={spanRef} />;
|
|
};
|
|
|
|
export default Yuan;
|
|
|