Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs Can';t将redux存储连接到语义ui调光器组件_Reactjs_Redux_Semantic Ui - Fatal编程技术网

Reactjs Can';t将redux存储连接到语义ui调光器组件

Reactjs Can';t将redux存储连接到语义ui调光器组件,reactjs,redux,semantic-ui,Reactjs,Redux,Semantic Ui,我正在使用React和语义ui React库。问题是,当我使用semantic ui Dimmer并尝试将其内部的组件连接到redux时,我得到了错误:未捕获不变冲突:在“connect(myComp)”上下文中找不到“store”。 我通过在提供程序中包装内部组件来克服此错误,如下所示: import { Dimmer } from 'semantic-ui-react' import { Provider } from 'react-redux' import store from '../

我正在使用React和语义ui React库。问题是,当我使用semantic ui Dimmer并尝试将其内部的组件连接到redux时,我得到了错误:
未捕获不变冲突:在“connect(myComp)”上下文中找不到“store”
。 我通过在提供程序中包装内部组件来克服此错误,如下所示:

import { Dimmer } from 'semantic-ui-react'
import { Provider } from 'react-redux'
import store from '../storelocation/store'
import SubComp from './subComp'

class App extends React.Component{
    render(){
        return(
            <div>
                <Dimmer>
                    <Provider store={store}>
                        <SubComp/>
                    </Provider>
                </Dimmer>
            </div>
        )
    }
}
ReactDom.render(
    <Provider store={store}>
        <App/>
    </Provider>, document.getElementById('root')
);

现在,由于每次使用我的SubComp时都会将其包装在provider中,这会使我脸上的笑容消失,因此我正在寻找一个更好的选择,如果我在这里犯了一些严重的错误,可能还会进行纠正。tnx.

这里出现的问题是因为语义UI React用于模态、确认、调光器、弹出窗口等组件

有关门户以及出现此问题的原因的更多信息,请参阅注释


不幸的是,到目前为止,似乎没有比通过提取存储(正如您所做的那样)将您自己的组件包装到门户下的提供者更好的方法了。

这里出现的问题是因为语义UI React用于组件,如模式、确认、调光器、弹出窗口等

有关门户以及出现此问题的原因的更多信息,请参阅注释


不幸的是,到目前为止,似乎没有比通过提取存储(正如您所做的那样)将您自己的组件包装到门户下的提供商更好的方法了。

谢谢您的回复。我没有更改代码,什么也没有崩溃!所以我想它看起来很难看,但它很管用。谢谢你的回复。我没有更改代码,什么也没有崩溃!所以我想它看起来很难看,但它很管用。