¿Cómo puedo importar un archivo JS con caracteres especiales en su nombre en React y JSX?
puedo
import { tomorrow} from 'react-syntax-highlighter/dist/esm/styles/hljs';
(la carpeta contiene mañana.js y mañana-noche.js)
pero no puedo:
import { tomorrow-night} from 'react-syntax-highlighter/dist/esm/styles/hljs';
No creo que la desestructuración funcione aquí porque es una declaración de importación.
puedes probar como
import * as Highlighter from 'react-syntax-highlighter/dist/esm/styles/hljs'; const TomorrowNight = Highlighter[`tomorrow-night`];¿Qué tal usar import * as blah import? Eso le da un objeto en el que luego puede buscar cualquier cadena.
import * as tmrw from from 'react-syntax-highlighter/dist/esm/styles/hljs'; const tmrw_night = tmrw['tomorrow-height']