如何限制草稿js中的最大字符?
我可以像这样得到状态的长度,但是如何停止更新组件?
var length = editorState.getCurrentContent().getPlainText('').length;
Run Code Online (Sandbox Code Playgroud) 我正在尝试为小型反应组件设置快照,但我不断收到以下错误
TypeError: val.getMockName is not a function
it('renders correctly', () => {
const wrapper = renderer.create(<Partners content={content} />).toJSON()
>
expect(wrapper).toMatchSnapshot()
^
})
Run Code Online (Sandbox Code Playgroud)
这是我的测试文件:
import React from 'react'
import renderer from 'react-test-renderer'
import Partners from './index'
import { content } from '../../content/anywhere-everywhere'
jest.mock('react-lazy-load', () => 'LazyLoad')
it('renders correctly', () => {
const wrapper = renderer.create(<Partners content={content} />).toJSON()
expect(wrapper).toMatchSnapshot()
})
Run Code Online (Sandbox Code Playgroud)
这是组件
import React from 'react'
import LazyLoad from 'react-lazy-load'
const Partners = ({ content }) => (
<section className="partners">
<h3>{content.partnersCopy}</h3>
<div className="partners__slider"> …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Typescript API 从从其他来源导入类型的 Typescript 文件中获取信息。
我有常见类型:
// example.types.ts
export interface Example<T> {
description: string;
title: string;
element: T;
}
Run Code Online (Sandbox Code Playgroud)
然后我想为其准备一些元素组件或类
// Canvas.ts
interface ICanvasConfig {
name: string;
size: {
width: number;
height: number;
};
}
export const Canvas = (config: ICanvasConfig): void => {
console.log(config);
};
Run Code Online (Sandbox Code Playgroud)
这是我要解析的目标文件
// Canvas.example.ts
import type { Example } from './example.types';
import { Canvas } from './Canvas';
const exampleMeta: Example<typeof Canvas> = {
title: 'Canvas Element',
description: 'Element used for..',
element: Canvas
};
export …Run Code Online (Sandbox Code Playgroud) abstract-syntax-tree typescript typescript-compiler-api ts-morph
arguments.callee不幸的是已弃用,在“严格模式”下使用它会引发错误。
是否有任何新的适当(标准)替代方法可以在实际函数中获取函数名称? 还是会出现在 ECMA6、7 的未来计划中?
最近的答案只不过是肮脏的黑客,对我来说是不可接受的答案。
和arguments.callee.caller.name不工作或者(V7.5.0的NodeJS)
我正在进入时,仪表板组件也会呈现/login.我需要在登录时省略仪表板组件.
确切的属性不适合,因为仪表板已嵌套的路径一样/dashboard/users,/dashboard/settings
<BrowserRouter>
<Route path='/'>
<div>
<Route path='/login' component={Login} exact />
<Route path='/' component={Dashboard} />
</div>
</Route>
</BrowserRouter>
Run Code Online (Sandbox Code Playgroud) 我使用Jest编写单元测试。
这是测试输出:
expect(string).toContain(value)
Expected string:
" input CreateBookInput {
title: String
author: String!
}
input UpdateBookInput {
title: String
author: String
}
"
To contain value:
"
input CreateBookInput {
title: String
author: String!
}
input UpdateBookInput {
title: String
author: String
}
"
Run Code Online (Sandbox Code Playgroud)
此测试失败。虽然这两个字符串的内容相同,但格式化程序不同。
我想要这个单元测试通过。我怎样才能做到这一点?
我试图在Android 2.3.3浏览器中测试Web应用程序.使用http://10.0.2.2连接结果"网页不可用".在Android Studio 文档中找不到任何内容.
有没有人遇到同样的问题?你是怎么解决的?
tortoisehg中的设置在代码预览中更改选项卡大小.默认设置为8,查看选项卡源不太舒服.
javascript ×4
jestjs ×2
reactjs ×2
android ×1
automocking ×1
draftjs ×1
ecmascript-6 ×1
localhost ×1
mercurial ×1
mocking ×1
node.js ×1
snapshot ×1
strict-mode ×1
tdd ×1
tortoisehg ×1
ts-morph ×1
typescript ×1