小编gar*_*ajo的帖子

如何明确地将商店作为道具传递给"Connect()"

我试图测试我的React组件并得到以下错误.

不变违规:无法在"连接()"的上下文或道具中找到"存储".将根组件包装在<Provider>中,或者显式地将"store"作为prop传递给"Connect()".

在测试中渲染Component时出错.

beforeEach(() => {
  Component = TestUtils.renderIntoDocument(<SideMenu />);
});
Run Code Online (Sandbox Code Playgroud)

在页面上呈现Component时,它工作正常.但是在测试中,我无法将存储明确地传递给Component.

有人能指出正确的方向吗?

phantomjs reactjs redux react-redux

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

如何推迟流读取调用

streams一般来说,我仍然试图改变自己的方式.我已经能够从内部使用multiparty流式传输大型文件form.on('part').但我需要推迟调用并在读取之前解析流.我曾尝试PassThrough,through.through2,但已经得到了不同的结果,它主要挂起,我无法弄清楚该怎么做,也没有步骤调试.我对所有选择都持开放态度.感谢您的所有见解.

import multiparty from 'multiparty'
import {
  PassThrough
} from 'stream';
import through from 'through'
import through2 from 'through2'

export function promisedMultiparty(req) {
  return new Promise((resolve, reject) => {

    const form = new multiparty.Form()
    const form_files = []
    let q_str = ''

    form.on('field', (fieldname, value) => {
      if (value) q_str = appendQStr(fieldname, value, q_str)
    })

    form.on('part', async (part) => {
      if (part.filename) {

        const pass1 = new PassThrough() // …
Run Code Online (Sandbox Code Playgroud)

javascript through2 node-streams multiparty

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