Skip to content

Commit 1823d38

Browse files
update index.js :
output component should not be memomized and updateTemplate method should be executed once in each render
1 parent 5712dae commit 1823d38

File tree

2 files changed

+6277
-6134
lines changed

2 files changed

+6277
-6134
lines changed

src/index.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
import React, { useRef } from "react";
2-
import Ctx from "./ctx.js";
1+
import React, {useRef} from 'react';
2+
import Ctx from './ctx.js';
33
window.React = window.React || React;
44
function StringToReactComponent(props) {
55
const ref = useRef(null),
66
template = props.children;
77
if (!ref.current) {
8-
ref.current = new Ctx(template);
8+
ref.current = new Ctx();
99
}
10-
const GeneratedComponent = ref.current
11-
.updateTemplate(template)
12-
.getComponent();
10+
const GeneratedComponent = ref.current.updateTemplate(template).getComponent();
1311
return <GeneratedComponent {...props} />;
1412
}
15-
export default React.memo(StringToReactComponent);
13+
export default StringToReactComponent;

0 commit comments

Comments
 (0)