babel

Jest from create-react-app not running on Windows

我们两清 提交于 2020-01-04 02:58:09
问题 I have a problem running Jest from a clean installed app created using create-react-app on Windows 8.1. After the installation, running the command npm run test , I get the error: No tests found related to files changed since last commit. Running jest --watchAll , so bypassing the react-scripts, in the same directory, though, shows: Test suite failed to run Jest encountered an unexpected token This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain

Vue知识点精简汇总

浪子不回头ぞ 提交于 2020-01-04 00:59:17
一、 组件component 1. 什么是组件? 组件(Component)是 Vue.js 最强大的功能之一。组件可以扩展 HTML 元素,封装可重用的代码 组件是自定义元素(对象) 2. 定义组件的方式 方式1:先创建组件构造器,然后由组件构造器创建组件 方式2:直接创建组件 3. 组件的分类 分类:全局组件、局部组件 4. 引用模板 将组件内容放到模板<template>中并引用 5. 动态组件 <component :is="">组件 多个组件使用同一个挂载点,然后动态的在它们之间切换 <keep-alive>组件 二、 组件间数据传递 1. 父子组件 在一个组件内部定义另一个组件,称为父子组件 子组件只能在父组件内部使用 默认情况下,子组件无法访问父组件中的数据,每个组件实例的作用域是独立的 2. 组件间数据传递 (通信) 2.1 子组件访问父组件的数据 a)在调用子组件时,绑定想要获取的父组件中的数据 b)在子组件内部,使用props选项声明获取的数据,即接收来自父组件的数据 总结:父组件通过props向下传递数据给子组件 注:组件中的数据共有三种形式:data、props、computed 2.2 父组件访问子组件的数据 a)在子组件中使用vm.$emit(事件名,数据)触发一个自定义事件,事件名自定义 b)父组件在使用子组件的地方监听子组件触发的事件

TypeError: Attempted to wrap undefined property as function

不羁的心 提交于 2020-01-03 17:05:49
问题 The example below is simplified. I have a getter method: class MyClass { constructor() {} get myMethod() { return true; } } which is processed by babel. And I want to mock it like this: var sinon = require('sinon'); var MyClass = require('./MyClass'); var cls = new MyClass(); var stub = sinon.stub(cls, 'myMethod'); stub.returns(function() { return false; }); But I get the following error: TypeError: Attempted to wrap undefined property myMethod as function And this happens on both version 1

URIError: Failed to decode param '/%PUBLIC_URL%/favicon.ico'

六眼飞鱼酱① 提交于 2020-01-03 09:51:29
问题 I am new to webpack and I got the babel loader and css loader to work and project compiles successfully but when I try to access via browser I get the below error. It looks as if PUBLIC_URL is not recognized. I I believe I don't know how to configure this. I appreciate your valuable comments. Thanks ℹ 「wdm」: Compiled successfully. URIError: Failed to decode param '/%PUBLIC_URL%/favicon.ico' at decodeURIComponent (<anonymous>) at decode_param (/home/mike/finance- grapher/node_modules/express

undefined is not a function (evaluating '_this._registerEvents()')

我的未来我决定 提交于 2020-01-03 09:07:11
问题 After i deleted my src folder in order to refactor this error occurred. I believe this is a caching issue? I tried following this gist but no luck. "react": "16.4.1", "react-native": "0.56.1", "@babel/core": "^7.1.2", "presets": ["react-native"] ` import React, { Component } from 'react'; import { Platform, Text, View } from 'react-native'; import { Provider } from 'react-redux'; import { store } from './src/redux/store'; export default class App extends Component<Props> { state = {

React changing input type via event

落花浮王杯 提交于 2020-01-03 03:10:06
问题 I'm trying to extend a React input component, which needs to be type password and after certain event on the element or element next to it - it needs to toggle the type of the input (type="text/password"). How this can be handled by React? I have this as class for my component: import { React, Component } from 'lib' export class PasswordInput extends Component { constructor(props, context){ super(props, context) const { type, validate, password } = this.props if(context.onValidate && password

bundling failed: Error: Cannot find module 'babel-preset-react-native' from '/workspace/reactnative''

和自甴很熟 提交于 2020-01-02 10:08:29
问题 I updated react-native to v0.57 and react-native run-ios is failing. I replaced babel-preset-react-native with metro-react-native-babel-preset as suggested in https://www.npmjs.com/package/babel-preset-react-native. here is the error stack trace I am getting. error: bundling failed: Error: Cannot find module 'babel-preset-react-native' from '/Users/buraktas/workspace/reactnative' - If you want to resolve "react-native", use "module:react-native" at Function.module.exports [as sync] (/Users

bundling failed: Error: Cannot find module 'babel-preset-react-native' from '/workspace/reactnative''

梦想的初衷 提交于 2020-01-02 10:08:11
问题 I updated react-native to v0.57 and react-native run-ios is failing. I replaced babel-preset-react-native with metro-react-native-babel-preset as suggested in https://www.npmjs.com/package/babel-preset-react-native. here is the error stack trace I am getting. error: bundling failed: Error: Cannot find module 'babel-preset-react-native' from '/Users/buraktas/workspace/reactnative' - If you want to resolve "react-native", use "module:react-native" at Function.module.exports [as sync] (/Users

Fabric.js with Typescript and Webpack: Canvas is not a constructor

戏子无情 提交于 2020-01-02 04:13:27
问题 I'm trying to use fabric.js with Typescript and Webpack aside some other modules in a Laravel 5.4 application that work fine in the browser. @types/fabric ist installed and Typescript behaves correct. New to Typescript as well as Webpack i tried some variants with no success. The problem result.js:198 Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_1_fabric___default.a.Canvas is not a constructor Variant A code.ts import fabric from "fabric"; const canvas = new fabric.Canvas('my-canvas');

Avoid an error when destructuring from undefined

不问归期 提交于 2020-01-02 02:01:09
问题 Lets say I have this code: const {x, y} = point; Babel will turn this into: var _point = point, x = _point.x, y = _point.y; Which is fine, but what if point is undefined? Now I get an error: "Cannot read property 'x' of undefined" . So how do I avoid this? I want to do something like const {x, y} = {} = point; but that's a syntax error. I can only see that this is an option: const {x, y} = point || {}; Which babel transpiles to: var _ref = point || {}, x = _ref.x, y = _ref.y; Here we're