Skip to content

Commit

Permalink
fix(infogram): add data-title attr and logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanwalters committed Mar 31, 2023
1 parent 8d64205 commit 7f447d1
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ const DefaultInfogram = ({ filename, title }) => {
const ref = useRef();

useEffect(() => {
console.log('infogram mount', filename, title);

const infographicContainer = ref.current;

let script;

if (infographicContainer) {
console.log('infogram if condition', filename, title);
script = document.createElement('script');

script.setAttribute('id', filename);
Expand All @@ -21,12 +24,13 @@ const DefaultInfogram = ({ filename, title }) => {
}

return () => {
console.log('infogram unmount', filename, title);
infographicContainer?.removeChild(script);
};
}, [filename, ref, title]);

return (
<div ref={ref} className={styles.DefaultInfogram} />
<div data-title={title} ref={ref} className={styles.DefaultInfogram} />
);
};

Expand Down

0 comments on commit 7f447d1

Please sign in to comment.