Is there a way to populate an Array with JSX Elements without encountering errors?
Consider the following scenario:
const arrayOfJsxElements : string[] = [];
arrayOfJsxElements.push(<div>hi</div>);
However, this approach results in the error 'Argument of type 'Element' is not assignable to parameter of type 'string'. ts(2345).' Is there a workaround for this issue?
I have managed to overcome this problem by using the following method:
import type { ReactElement } from 'react' const arrayOfJsxElements : ReactElement[] = []; arrayOfJsxElements.push(<div>hi</div>);
Although this solution works, I am searching for a simpler alternative that does not require importing dependencies every time. Any suggestions on what type should be used for JSX Elements?