Importing es6 in create-react-app: wrong URL.
See original GitHub issueI’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:
- Created 5 years ago
- Comments:9 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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’;
For TinyMCE 5+ there’s no need to include the skin url to include the css. You can import them all in your component: