import { useMemo } from 'react' ; const Babel = require ( '@babel/standalone' ) ; /**
 * Compiles a string using Babel.
 */ const useBabel = ( source ) : [ Error | null , string | null ] => { const [ error , compiled ] = useMemo ( ( ) => { try { const code = Babel . transform ( source , { presets : [ 'es2015' , 'react' ] } ) . code ; return [ null , code ] ; } catch ( error ) { return [ error , null ] ; } } , [ source ] ) ; return [ error , compiled ] ; } ; export default useBabel ;