mirror of https://github.com/grafana/grafana.git
				
				
				
			
		
			
				
	
	
		
			14 lines
		
	
	
		
			403 B
		
	
	
	
		
			TypeScript
		
	
	
	
			
		
		
	
	
			14 lines
		
	
	
		
			403 B
		
	
	
	
		
			TypeScript
		
	
	
	
| import { cloneElement, forwardRef, Ref } from 'react';
 | |
| 
 | |
| interface ConditionalWrapProps {
 | |
|   shouldWrap: boolean;
 | |
|   children: JSX.Element;
 | |
|   wrap: (children: JSX.Element) => JSX.Element;
 | |
| }
 | |
| 
 | |
| function ConditionalWrap({ children, shouldWrap, wrap }: ConditionalWrapProps, _ref: Ref<HTMLElement>) {
 | |
|   return shouldWrap ? cloneElement(wrap(children)) : children;
 | |
| }
 | |
| 
 | |
| export default forwardRef(ConditionalWrap);
 |