How to add an autoimport to WebStorm Live Templates

255 Views Asked by At

I have a live template useS for

const [$VAR1$, set$VAR2$] = useState($END$);

where useState is an external variable that has to be imported like so:

import { useState } from "react";

Whenever this template is used, the import should be automatically added to the current file at the top.

The template is used within JS functions, therefore I can not just add an import to the live template, since the import will be placed inline then.

Is there a special pattern for that?

1

There are 1 best solutions below

0
lena On BEST ANSWER

Doesn't work currently, please follow WEB-37425 for updates