小编mic*_*blu的帖子

Git:在本地合并Remote分支

我通过拉了所有远程分支机构git fetch --all.我可以通过git branch -aremotes/origin/branchname 看到我想要合并的分支.问题是它无法访问.我不能合并或结账?

git branch repository git-branch

174
推荐指数
4
解决办法
28万
查看次数

为什么要使用redux-thunk?

我不明白需要什么redux-thunk.据我所知,a thunk是一个返回函数的函数.在我看来,包装的表达式和中间件的使用可以做更多的工作来模糊正在发生的事情.取自redux-thunk的示例代码

import thunk from 'redux-thunk';

// Note: this API requires redux@>=3.1.0
const store = createStore(
  rootReducer,
  applyMiddleware(thunk)
);


// Meet thunks.
// A thunk is a function t hat returns a function.
// This is a thunk.

function makeASandwichWithSecretSauce(forPerson) {

  // Invert control!
  // Return a function that accepts `dispatch` so we can dispatch later.
  // Thunk middleware knows how to turn thunk async actions into actions.

  return function (dispatch) {
    return fetchSecretSauce().then(
      sauce …
Run Code Online (Sandbox Code Playgroud)

javascript typescript reactjs redux-thunk react-redux

21
推荐指数
1
解决办法
9800
查看次数

如何让Grunt-Contrib-Copy复制相对于给定源路径的文件/目录

第一次使用此任务,我正在尝试实现的目标如下:

从复制所有目录/文件src/js/bower_components/*build/assets/js/vendor/

我尝试过使用cwd属性但是当我使用它时它根本不起作用..我已经将它设置为:src/js/bower_components/

来自src

.
??? Gruntfile
??? src
    ??? js
        ??? bower_components
            ??? jquery
Run Code Online (Sandbox Code Playgroud)

我目前得到:

.
??? Gruntfile
??? build
    ??? assets
        ??? js
            ??? vendor
                src
                ??? js
                    ??? bower_components
                        ??? jquery
Run Code Online (Sandbox Code Playgroud)

我想要什么

.
??? Gruntfile
??? build
    ??? assets
        ??? js
            ??? vendor
                ???jquery
Run Code Online (Sandbox Code Playgroud)

这是我目前的咕噜声任务

copy: {
  main: {
    src: 'src/js/bower_components/*',
    dest: 'build/assets/js/vendor/',
    expand: true,
  }
},
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助

javascript copy gruntjs grunt-contrib-copy

17
推荐指数
1
解决办法
2万
查看次数

Typescript:如何管理类型声明冲突的依赖关系?

我有错误:Subsequent variable declarations must have the same type

发生这种情况是因为我需要两个依赖项;声明相同的类型。

开玩笑/node_modules/@types/jest/index.d.ts=>declare var test: jest.

测试咖啡馆 node_modules/testcafe//ts-defs/index.d.ts=>declare var test: TestFn;

我的项目是一个使用 webpack、babel 和 Typescript 的 React/Redux 项目。

当我运行我的开发服务器时,会发生错误,npm start该服务器使用webpack-dev-server. 当我运行时它也会产生一个问题,jest因为它使用 testcafe 的声明Test类型版本。

如何解决这个问题?

javascript types typescript jestjs testcafe

6
推荐指数
1
解决办法
2274
查看次数

如何从简单的 Ruby 服务器捕获 POST 数据

我有一个基本的 Ruby 服务器,我想侦听特定端口,读取传入的 POST 数据并执行等等...

我有这个:

require 'socket'               # Get sockets from stdlib

server = TCPServer.open(2000)  # Socket to listen on port 2000
loop {                         # Servers run forever
  client = server.accept       # Wait for a client to connect
  client.puts(Time.now.ctime)  # Send the time to the client
  client.puts "Closing the connection. Bye!"
  client.close                 # Disconnect from the client
}
Run Code Online (Sandbox Code Playgroud)

我将如何捕获 POST 数据?

谢谢你的帮助。

ruby http-post

5
推荐指数
2
解决办法
3521
查看次数

tsconfig.json 显然被忽略了?

我需要帮助来理解为什么我的 tsconfig.json 被忽略?tsconfig.json 的目标是es5,但我仍然收到此错误?

我有以下目录:

  • 测试.ts
  • tsconfig.json

测试.ts

let passcode = "roscoes"

class Employee {
    private _fullName: String

    get fullName(): String {
        return this._fullName
    }

    set fullName(newName: String) {
        if (passcode && passcode === "roscoes") {
            this._fullName = newName
        } else {
            console.log("Error: Not authorized ")
        }
    }
}
let employee = new Employee()
employee.fullName = "Johnny Appleseed"

if (employee.fullName) {
    console.log(employee.fullName)
}

console.log('testing')
Run Code Online (Sandbox Code Playgroud)

tsconfig.json

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es6"
    },
    "files": [
        "./**/*.ts"
    ]
} …
Run Code Online (Sandbox Code Playgroud)

javascript typescript

4
推荐指数
1
解决办法
1571
查看次数

Babel Jest无法与已加载的CSS模块一起使用

使用笑话运行简单的组件测试时,出现以下错误。

FAIL  src/components/header/Header.test.tsx
  ? Test suite failed to run

    /Volumes/WorkSpace/Projects/wc2/src/components/header/Header.scss:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){@import "../../styles/variables";
                                                                                             ^
    SyntaxError: Invalid or unexpected token

      at ScriptTransformer._transformAndBuildScript (../../../../Users/micahblu/.nvm/versions/node/v7.2.0/lib/node_modules/jest/node_modules/je
st-runtime/build/ScriptTransformer.js:289:17)
      at Object.<anonymous> (src/components/header/Header.tsx:2:1)
Run Code Online (Sandbox Code Playgroud)

该组件导入header.scss。原始错误抱怨我在文件开头有@import语句,但甚至删除它也抱怨“。”。在CSS类声明的开头。显然对CSS根本不起作用?还是scss?我拥有适用于css和sass的所有适当的babel加载程序,并且它们在开发中运行良好,我认为babel-jest应该了解如何处理文件。

在我的package.json中,我有:

"jest": {
    "transform": {
      "^.+\\.(tsx|ts)?$": "typescript-babel-jest"
    },
    "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "json"
    ]
  }
Run Code Online (Sandbox Code Playgroud)

Header.test.tsx

import React from 'react'
import renderer from 'react-test-renderer'
import Header from './Header'

test('output', () => {
  const component = renderer.create(<Header />)
  expect(component).toMatchSnapshot()
})
Run Code Online (Sandbox Code Playgroud)

头文件

import React from 'react'
import { Link } from 'react-redux-router'
import …
Run Code Online (Sandbox Code Playgroud)

babel typescript jestjs babel-jest

1
推荐指数
1
解决办法
1032
查看次数

当状态更新时,我失去了对动态创建的 jsx 输入的关注

我有许多从数组动态生成的字段,并绑定到 redux 状态分支。输入值正确映射到状态,然后返回到组件。问题是它失去焦点,您必须重新单击输入元素。我试图通过自动聚焦最后更新的字段来解决这个问题,但它聚焦在文本的开头,这样你就可以向后写。我寻找该问题的解决方案,但它们都需要直接在 dom 上工作或使用“onFocus =“this.value = value”,作为 jsx 属性将不起作用。

我在这里做错了什么吗?为什么 React 不像静态 jsx 输入元素那样自动记住要聚焦的字段?

这是生成字段的代码:

const renderFields = (fields, target) => {
    if(!fields) return <div></div>
    return fields.map(field => {
      let input = []
      if(field.type==="text") {
        input.push(<input key={generateUID()} type="text" onChange={e=>onChange(field, e.target.value, target)} autoFocus={field.hasFocus} value={field.value} />)
      } else if(field.type==="radio") {
        let values = field.control.match(/\[(.+)\]/)[1].split(",")
        input = values.map(value => {
          return (<label key={generateUID()}><input name={field.id} onChange={e=>onChange(field, value, target)} type="radio" value={value} key={generateUID()} style={{display: "inline-block"}} /> {value}</label>)
        })
      }
      return (
        <div key={generateUID()}>
          <label>{field.label}</label>
          <br …
Run Code Online (Sandbox Code Playgroud)

javascript jsx reactjs redux

1
推荐指数
1
解决办法
1242
查看次数

在React-Day-Picker中禁用所有以后的日子吗?

我有一个使用react-day-picker的日期范围日历。除了不能从选择中禁用“所有”将来的日子以外,它的工作非常漂亮。api文档显示您可以输入一天或几天,但不能输入所有将来的日子?

      <DayPicker
        disabledDays={new Date()} // how to disable all days after today?
        modifiers={{
          sunday: day => day.getDay() === 0,
          firstOfMonth: day => day.getDate() === 1
        }}
        onDayClick={this.handleDayClick}
        onDayMouseEnter={this.handleDayMouseEnter}
      />
Run Code Online (Sandbox Code Playgroud)

reactjs react-day-picker

1
推荐指数
2
解决办法
1715
查看次数