File tree Expand file tree Collapse file tree 2 files changed +15
-12
lines changed Expand file tree Collapse file tree 2 files changed +15
-12
lines changed Original file line number Diff line number Diff line change 1
- import React , { useRef } from 'react' ;
2
1
import Ctx from './ctx.js' ;
3
- window . React = window . React || React ;
4
- function StringToReactComponent ( props ) {
5
- const ref = useRef ( null ) ,
6
- template = props . children ;
7
- if ( ! ref . current ) {
8
- ref . current = new Ctx ( ) ;
9
- }
10
- const GeneratedComponent = ref . current . updateTemplate ( template ) . getComponent ( ) ;
11
- return < GeneratedComponent { ...props } /> ;
12
- }
13
- export default StringToReactComponent ;
2
+ import StringToReact from './strintToReact.js' ;
3
+ const getCtx = ( ) => new Ctx ( ) ;
4
+ export default StringToReact . bind ( null , { getCtx} ) ;
Original file line number Diff line number Diff line change
1
+ import React , { useRef } from 'react' ;
2
+ window . React = window . React || React ;
3
+ function StringToReactComponent ( { getCtx} , props ) {
4
+ const ref = useRef ( null ) ,
5
+ template = props . children ;
6
+ if ( ! ref . current ) {
7
+ ref . current = getCtx ( ) ;
8
+ }
9
+ const GeneratedComponent = ref . current . updateTemplate ( template ) . getComponent ( ) ;
10
+ return < GeneratedComponent { ...props } /> ;
11
+ }
12
+ export default StringToReactComponent ;
You can’t perform that action at this time.
0 commit comments