小编bes*_*ant的帖子

运行故事书时出错 - sh: 1: start-storybook: 未找到

我在运行故事书时遇到错误...即使是在全新安装的情况下也是如此。

 npm run storybook

> @ storybook /media/programmersedge/New_Volume/devs/demostorybook
> start-storybook -p 9001 -c .storybook

sh: 1: start-storybook: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! @ storybook: `start-storybook -p 9001 -c .storybook`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the @ storybook script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Run Code Online (Sandbox Code Playgroud)

我正在使用最新的故事书版本。我的节点 …

npm reactjs yarnpkg storybook

25
推荐指数
4
解决办法
5万
查看次数

如何在TypeScript中合并两个枚举

假设我有两个枚举,如下面的Typescript中所述,那么我如何合并它们

enum Mammals {
    Humans,
    Bats,
    Dolphins
}

enum Reptiles {
    Snakes,
    Alligators,
    Lizards
}

export default Mammals & Reptiles // For Illustration purpose, Consider both the Enums have been merged.
Run Code Online (Sandbox Code Playgroud)

现在,当我importexported value另一个文件中,我应该能够从两个枚举访问值.

import animalTypes from "./animalTypes"

animalTypes.Humans //valid

animalTypes.Snakes // valid
Run Code Online (Sandbox Code Playgroud)

如何在Typescript中实现此类功能?

merge enums types typescript typescript2.0

15
推荐指数
5
解决办法
1万
查看次数

在Typescript中将字符串数组转换为枚举

我在玩打字稿一点。

假设我有一个object这样的

let colors = {
    RED: "r",
    GREEN: "g",
    BLUE: "b"
}
Run Code Online (Sandbox Code Playgroud)

现在我想把它转换成一种enum类型

enum Colors = {
    RED = "r",
    GREEN = "g",
    BLUE = "b"
}
Run Code Online (Sandbox Code Playgroud)

更新:

我想要typings颜色对象生成,这样如果我key向颜色对象添加另一个,它应该包含在typings.

如果我做

colors['YELLOW'] = "y"
Run Code Online (Sandbox Code Playgroud)

那么生成的typings应该是

declare enum colors {
    RED = "r",
    GREEN = "g",
    BLUE = "b",
    YELLOW = "y"
}
Run Code Online (Sandbox Code Playgroud)

相反,生成类型是

declare const colors {
     [x: string]: string        
}
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

arrays enums types object typescript

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

React.CloneElement返回一个对象而不是函数

我很难理解React.cloneElement()功能的行为

我的组件结构是这样的

A.js

export default class A extends React.Component {
     render() {
         return (<h1>{ this.props.message }</h1>)
     }
 }
Run Code Online (Sandbox Code Playgroud)

B.js

import A from "./A"

const newComponent = React.cloneElement(A,{
    message: "Hello World"
})

export default newComponent
Run Code Online (Sandbox Code Playgroud)

C.js

import B from "./B"
import { BrowserRouter as Router, Route } from "react-router-dom"

// To Be very precise
 export default class C extends React.Component {
     render() {
         return (
             <Router>
                <Route path="/" component={B}  />
            </Router>
         )
     }
 }
Run Code Online (Sandbox Code Playgroud)

但是我得到了这个错误

提供给component类型的无效道具,预期.object …

components clone element reactjs

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

如何使用 Typescript 中的装饰器向类添加静态属性

我正在尝试使用装饰器向类添加一些属性。但我收到编译时错误。我的代码结构有点像这样。

type ModuleConfig = {
    ModuleName: string
    // ...other properties
}

type ModuleClass = {
    ModuleName: string
}

type TargetClass = {}

function Module(moduleConfig: ModuleConfig ): Function {
    return function(targetClass: TargetClass): ModuleClass {
        Object.defineProperty(targetClass,"ModuleName", { value: moduleConfig.ModuleName })

        // ...Define other properties in targetClass based on other properties of moduleConfig.

        return <ModuleClass>targetClass
    }
}

==================================

@Module({
    ModuleName: "App"
    // ...other properties
})
class AppModule {}

===================================


let Config = {
    RootModule: AppModule,
    modules:[
        // other Modules
    ]
}

===================================

type …
Run Code Online (Sandbox Code Playgroud)

decorator typescript typescript-typings

6
推荐指数
0
解决办法
1590
查看次数

为 React 应用程序开发一个 Redux 存储作为单独的 NPM 模块

是否可以将React AppRedux Store作为单独的npm 包开发,然后在React App 中开发Storeimport

例如:我有一个名为reactapp.

我开发了一个名为包reactapp-reduxstore包含Redux的商店,它的操作减速

现在,我将其导入reactapp-reduxstore到我的reactapp项目中

// other imports

import { store } from 'reactapp-reduxstore'

const ReactApp = () => (
<Provider store={store}>
    // React App Components
<Provider/>
)

// Mount ReactApp to DOM
Run Code Online (Sandbox Code Playgroud)

现在,如果我想使用我的redux 存储包中的操作,我会将操作导入到组件中。

import { addUser } from "reactapp-reduxstore/users"

// Use the action in my Component
Run Code Online (Sandbox Code Playgroud)

我只想知道, …

javascript modularity npm reactjs redux

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

刷新令牌被 Laravel Passport 中的访问令牌撤销

我正在使用laravel/passport password_grant进行身份验证。整个生成access_tokenrefresh_token过程工作正常。现在我正在尝试使用 Laravel 护照令牌事件来撤销旧令牌。

我参考了这篇文章的过程 - https://laracasts.com/discuss/channels/laravel/laravel-passport-revoke-and-prune-event-listener-is-not-doing-anything

这有效......但是当access token使用先前提供的刷新时refresh tokenaccess token正在创建一个新的并创建一个新的refresh token存在。最终,在撤销 old 时access token, old, not expiredrefresh token也被撤销。

但我认为,refresh token只有在它到期时才必须撤销。

而且当我EventListenersApp\Providers\EventServiceProvider $listen array 中删除时,撤销机制仍然有效。

这就像拔掉插头灯泡仍然亮着一样。

如何解决这个问题?还是我在某个地方的概念有误?

authentication access-token laravel refresh-token laravel-passport

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

忽略 PHPUnit 9 中的弃用通知?

我使用 PHPUnit 9 运行测试,当我这样做时,assertRegExp我收到警告

assertRegExp() is deprecated and will be removed in PHPUnit 10. Refactor your code to use assertMatchesRegularExpression() instead.

Run Code Online (Sandbox Code Playgroud)

如何抑制特定测试的弃用警告?

注意:-我使用 Laravel Dusk 来运行我的测试,并使用测试助手assertPathIs

testing phpunit laravel laravel-dusk

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

如何在Markdown中制作罗马数字列表?

如何在Markdown中创建罗马数字列表

像这样...

i)更高的每英亩甘蔗田。
ii)甘蔗中蔗糖含量较高。
iii)降低人工成本。
iv)更长的破碎时间。

markdown list roman-numerals

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

使用自定义包的配置文件而不在Laravel 5中发布*

我的Laravel自定义软件包有一个配置文件。

目前,我正在按照docs中所述通过发布自定义包的配置文件来使用它。

我只想澄清一下,有没有一种方法可以使用自定义包的配置文件而不在Laravel 5中发布它?*

publish config package laravel laravel-5

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