ecmascript-6

dependency cycle detected import/no-cycle

戏子无情 提交于 2021-01-27 02:25:29
问题 I am trying to set up API endpoints in ES6. In my main server file, I tried to import the router module but I get the error "dependency cycle detected import/no-cycle". Please find my code below for clearance and assistance. import express from 'express'; import bodyParser from 'body-parser'; import router from './routes/routes'; const app = express(); const PORT = process.env.PORT || 8080; app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); // app.use(routes); app

Exporting functions with reactjs and babel

假装没事ソ 提交于 2021-01-27 02:09:31
问题 I have a project using reactjs, which is transpiled by babel. I use the es2015 and react transforms in my .babelrc . I am currently refactoring and in my first pass I basically did export class foo for everything I needed. A lot of these classes should really just be functions, so I am trying to rewrite them as such, but I keep getting the same error. My main application file looks somethings like this: import React, { Component } from 'react'; import {Foo, Bar} from './components/ui.js';

Exporting functions with reactjs and babel

南楼画角 提交于 2021-01-27 02:05:06
问题 I have a project using reactjs, which is transpiled by babel. I use the es2015 and react transforms in my .babelrc . I am currently refactoring and in my first pass I basically did export class foo for everything I needed. A lot of these classes should really just be functions, so I am trying to rewrite them as such, but I keep getting the same error. My main application file looks somethings like this: import React, { Component } from 'react'; import {Foo, Bar} from './components/ui.js';

Object Literal Property Value Shorthand incompatible with `this`

怎甘沉沦 提交于 2021-01-27 01:57:22
问题 In JavaScript it is possible to do: var a = {this: this} but with ES6 property shorthand I get SyntaxError: var b = {this}; // SyntaxError: this is a reserved identifier This is not a real use case but I am just wondering what is the difference between these two. I thought it should do the same (either create a new object or throw an error). UPDATE: I run this example in Firefox 42.0. However it works in babel-node (it creates object { this: {} } without error). So what's the correct behavior

Object Literal Property Value Shorthand incompatible with `this`

一笑奈何 提交于 2021-01-27 01:56:39
问题 In JavaScript it is possible to do: var a = {this: this} but with ES6 property shorthand I get SyntaxError: var b = {this}; // SyntaxError: this is a reserved identifier This is not a real use case but I am just wondering what is the difference between these two. I thought it should do the same (either create a new object or throw an error). UPDATE: I run this example in Firefox 42.0. However it works in babel-node (it creates object { this: {} } without error). So what's the correct behavior

Proxy object cannot be added to DOM (traps doesn't trigger either)

岁酱吖の 提交于 2021-01-26 09:46:42
问题 I am trying to make a Proxy object of Image to trap properties but even with an empty handler I get an error message. TypeError: Argument 1 of Node.appendChild does not implement interface Node. The proxy object is suppose to act as the target object so this baffles me a little. As far as I understand you should be able to do this with DOM nodes as well (?). Also : I cannot start loading the image and have the onload handler triggered when setting the src property. How should I use the Proxy

Imported variable works but is not defined when accessed in debugger (within same scope)

為{幸葍}努か 提交于 2021-01-26 03:37:47
问题 I am using webpack + es6 to build my files. I exported modules in a Math.js, then imported in Main.js. In the latter, I used the module to compute, then set a stop in the debugger. The former worked but it was not defined when I tried to use it in the console. The scope is the same - why would the module not be defined in the console? // Math.js export function sum(x, y) { return x + y; } export var pi = 3.141593; // Main.js import * as mathTest from "./Math.js"; console.log("2π = " +

Uncaught Error:expected a string. You forgot export your component from the file its defined,or you might have mixed up default/named import

只愿长相守 提交于 2021-01-22 08:54:50
问题 Could you please help me to resolve the issue. I have already tried resolving the import functions but i still get that error and I have also tried to remove "{}" which didnt work. Thanks in advance. I am following TylerMcginnis React-Redux course. Navigation.js import React from 'react' import PropTypes from 'prop-types' import Link from 'react-router-dom' import { container, navContainer, link } from './styles.css' Navigation.propTypes = ActionLinks.propTypes = NavLinks.propTypes = {

Uncaught Error:expected a string. You forgot export your component from the file its defined,or you might have mixed up default/named import

狂风中的少年 提交于 2021-01-22 08:53:20
问题 Could you please help me to resolve the issue. I have already tried resolving the import functions but i still get that error and I have also tried to remove "{}" which didnt work. Thanks in advance. I am following TylerMcginnis React-Redux course. Navigation.js import React from 'react' import PropTypes from 'prop-types' import Link from 'react-router-dom' import { container, navContainer, link } from './styles.css' Navigation.propTypes = ActionLinks.propTypes = NavLinks.propTypes = {

React Redux form and connect syntax

試著忘記壹切 提交于 2021-01-21 08:58:07
问题 I have a React component export class Login extends Component { ..omitted for clarity } export default connect(select, actions)(Login); And as can be seen it connects to Redux and it works perfectly well I have Redux Form as export class ChangePassword extends Component { ..omitted for clarity } export default reduxForm({ form: 'change_password_form', validate })(ChangePassword); Again this is working perfectly well. My question is , I can't work out the syntax to have the Redux form also to