Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration with react-boilerplate #360

Closed
henviso opened this issue Jan 19, 2018 · 8 comments
Closed

Integration with react-boilerplate #360

henviso opened this issue Jan 19, 2018 · 8 comments

Comments

@henviso
Copy link

henviso commented Jan 19, 2018

Problem

Hello guys, I'm new to react-ace, very nice project by the way, I liked a lot.
I have a very noob question, I just bootstraped a project with https://github.com/react-boilerplate/react-boilerplate, added react-ace as a dependency and everything seems to be working fine.

But I'm getting the error above on the console:

_mode-mode.js:1 Uncaught SyntaxError: Unexpected token <_

It seems that it is something about webpack configuration between both projects? Can you guys recommend anything about this setup?

This is the way I'm using react-ace:

import React, { Component } from 'react';
import AceEditor from 'react-ace';
import messages from './messages';

import 'brace/theme/github';

export default class HomePage extends Component { // eslint-disable-line react/prefer-stateless-function
  render() {
    return (
      <div>
        <AceEditor
          mode=""
          theme="github"
          onChange={() => null}
          name="UNIQUE_ID_OF_DIV"
          editorProps={{ $blockScrolling: true }}
        />
      </div>
    );
  }
}
@securingsincity
Copy link
Owner

@henviso you need to set a mode and import those themes and modes separately as shown in the basic usage in the readme https://github.com/securingsincity/react-ace#basic-usage .

@fbove
Copy link

fbove commented Oct 23, 2018

It's happening to me as well, and I have those imports declared. This is my code:

import AceEditor from 'react-ace'
import 'brace/mode/python'
import 'brace/theme/monokai'
// ...
<AceEditor
  name="ACE_EDITOR"
  value={this.props.value}
  mode="python"
  theme="monokai"
/>

It also works, but in the console it throws:
Uncaught SyntaxError: Unexpected token < python.js:1
And if I go to that file, hosted on /snippets/python.js, it shows my index.html

So my guess is that I'll need to add some extra config on webpack in order to copy that required JS (/brace/snippets/python.js) to a public location; using copy-webpack-plugin.

Any thoughts?

@IshaTr
Copy link

IshaTr commented Dec 10, 2018

@fbove Try importing import brace from 'brace'; on the top of both the mode and theme imports.
worked for me.

@mwb-27
Copy link

mwb-27 commented May 11, 2019

@fbove i have the same question, and i don't want to validate text in any programming language,how can i set mode

@henviso henviso closed this as completed Jun 24, 2019
@hpsaah
Copy link

hpsaah commented Jun 25, 2019

I'm importing import brace from 'brace'; but still showing the same error

@ningcui-compass
Copy link

I have the same issue and import 'brace' doesn't work for me.

@ningcui-compass
Copy link

ningcui-compass commented Sep 16, 2019

Found the solution: you must specify a mode when using AceEditor

@MalekBouba
Copy link

MalekBouba commented Nov 23, 2021

Still have the same issue.

"react": "^17.0.2",
"react-ace": "^9.5.0",

and

<AceEditor
    mode="json"
    theme="solarized_dark"
    // ...
/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants