File tree Expand file tree Collapse file tree 4 files changed +6277
-6137
lines changed Expand file tree Collapse file tree 4 files changed +6277
-6137
lines changed Original file line number Diff line number Diff line change 11class Ctx {
2- constructor ( ) {
2+ constructor ( React ) {
33 this . _temp = '' ;
44 this . _parentTemp = `"use strict";\nreturn @temp;` ;
55 this . _com = null ;
6+ window . React = window . React || React ;
67 if ( ! ( Object . prototype . hasOwnProperty . call ( window , 'Babel' ) && typeof window . Babel === 'object' ) ) {
78 throw new Error ( `string-to-react-component package needs @babel/standalone for working correctly.
89 you should load @babel/standalone in the browser.` ) ;
Original file line number Diff line number Diff line change 11import Ctx from './ctx.js' ;
22import StringToReact from './strintToReact.js' ;
3- const getCtx = ( ) => new Ctx ( ) ;
3+ const getCtx = ( options ) => new Ctx ( options ) ;
44export default StringToReact . bind ( null , { getCtx} ) ;
Original file line number Diff line number Diff line change 1- import React , { useRef } from 'react' ;
1+ import React , { useRef } from 'react' ;
22import PropTypes from 'prop-types' ;
3- window . React = window . React || React ;
43function StringToReactComponent ( { getCtx} , props ) {
54 const ref = useRef ( null ) ;
6- if ( ! ref . current ) {
7- ref . current = getCtx ( ) ;
8- }
5+ ref . current = ref . current || getCtx ( React ) ;
96 const babelOptions = props . babelOptions || { } ;
107 const GeneratedComponent = ref . current . updateTemplate ( props . children , babelOptions ) . getComponent ( ) ;
118 const data = props . data || { } ;
You can’t perform that action at this time.
0 commit comments