question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Importing es6 in create-react-app: wrong URL.

See original GitHub issue

I’m using create-react-app with this.

If I follow this guide: https://www.tiny.cloud/docs/integrations/react/ it works using:

<script src="https://cloud.tinymce.com/stable/tinymce.min.js"></script>

in my index.html.

But if I try to use https://www.tiny.cloud/docs/advanced/usage-with-module-loaders/#es2015modules working with Javascript imports it doesn’t work anymore.

If I simply use this code as suggested:

import React, { Component } from "react";
import { Editor } from "@tinymce/tinymce-react";
// Import TinyMCE
import tinymce from 'tinymce/tinymce';
// A theme is also required
import 'tinymce/themes/modern/theme';

class App extends React.Component {
  handleEditorChange = (e) => {
    console.log('Content was updated:', e.target.getContent());
  }

  render() {
    return (
      <Editor
        initialValue="<p>This is the initial content of the editor</p>"
        init={{
          plugins: 'link image code',
          toolbar: 'undo redo | bold italic | alignleft aligncenter alignright | code'
        }}
        onChange={this.handleEditorChange}
      />
    );
  }
}

it try to load files from: http://localhost:4000/static/js/skins/lightgray/content.min.css.

But that link doesn’t exists on my create-react-app server!

Here a reproduction: https://codesandbox.io/s/q3xzqxllkq

How to fix?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Gunyoncommented, Jul 9, 2020

I’m getting this error:

Refused to apply style from ‘URL/static/js/skins/ui/oxide/skin.min.css’ because its MIME type (‘text/html’) is not a supported stylesheet MIME type, and strict MIME checking is enabled. Refused to apply style from ‘URL/static/js/skins/ui/oxide/content.inline.min.css’ because its MIME type (‘text/html’) is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Also need to import icons: import ‘tinymce/icons/default’;

2reactions
shaysegevcommented, Apr 15, 2019

For TinyMCE 5+ there’s no need to include the skin url to include the css. You can import them all in your component:

// Import TinyMCE and theme
import 'tinymce'
import 'tinymce/themes/silver' // was changed from modern to silver

// Import skin
import 'tinymce/skins/ui/oxide/skin.min.css'
import 'tinymce/skins/ui/oxide/content.min.css'

// Import plugins
import 'tinymce/plugins/print'
import 'tinymce/plugins/preview'
...
Read more comments on GitHub >

github_iconTop Results From Across the Web

React | import images from URL-holding variables - why am I ...
Based on the static/media/ path, I'm guessing that you're using create-react-app , which will take images and other static assets and place ...
Read more >
Error Boundaries - React
In practice, most of the time you'll want to declare an error boundary component once and use it throughout your application. Note that...
Read more >
Migrating from Create React App - Next.js
With Create React App, you can import .css files directly inside React components. Next.js allows you to do the same, but requires these...
Read more >
React Getting Started - W3Schools
If you have npx and Node.js installed, you can create a React application by using create-react-app . If you've previously installed create-react-app globally, ......
Read more >
React JavaScript Tutorial in Visual Studio Code
Create a new H1 header with "Hello, world!" and replace the <App /> tag in ReactDOM.render with element . import React from 'react' ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found