TransWikia.com

How to import react libraries into pure jsx file

Stack Overflow Asked by DannyCranfield on August 17, 2020

I’m following this tutorial.

It uses JSX files to contain the relevant react code for each component of the system so Home, Index etc along with a corresponding HTML file.

I’m used to using pure React where I can import libraries by using the import keyword.

However in JSX it seems I have to declare the libraries differently by importing them into the HTML via script sources.

How would I go about importing this text editor library which is for ReactJS when it expects the typical import call.

I’ve tried following the current architecture from the tutorial by declaring it differently in the JSX file as var SunEditor = 'suneditor-react';

This does not work, I’ve had to instead import the pure Javascript version of the library which is the first one here. As by using the pure JS version I can simply import via script references in the corresponding HTML file that matches the given JSX file.
i.e. <script src="https://cdn.jsdelivr.net/npm/suneditor@latest/dist/suneditor.min.js"></script>

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP