Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.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
Javascript 多次显示同一组件时共享会话_Javascript_Reactjs - Fatal编程技术网

Javascript 多次显示同一组件时共享会话

Javascript 多次显示同一组件时共享会话,javascript,reactjs,Javascript,Reactjs,我有一个组件(作为a)应该在模态中加载其他组件(作为B) 在B的componentDidMount中,我有这些api调用(嵌套),它们都失败了: componentDidMount() { ApiService.openProject(this.props.projectName).then(() => { ApiService.getConfigTables(this.props.config).then((response) => {

我有一个组件(作为a)应该在模态中加载其他组件(作为B)

在B的componentDidMount中,我有这些api调用(嵌套),它们都失败了:

componentDidMount() {
    ApiService.openProject(this.props.projectName).then(() => {
        ApiService.getConfigTables(this.props.config).then((response) => {
            this.setState({
                    configTables: response
                }
            )
        })
    });
}
如果我在调用第一个api调用时在服务器端以断点停止,则继续这两个调用

在组件A中,我具有模态:

{ this.configuration !== null ?
            <ComposedModal
                open={this.state.openShowData}
                onClose={() => this.toggleShowDataModal(false)}
                height={500}
                className="some-class"
            >
            <ModalHeader title="" className="">

            </ModalHeader>

            <ModalBody>
                <B projectName={this.projectName} config={this.configuration}/>
            </ModalBody>
{this.configuration!==null?
this.toggleShowDataModal(false)}
高度={500}
className=“某个类”
>
我意识到,当我在同一个页面(使用同一个会话)中显示多个组件时,就会出现问题。如果我只显示了B的一个分量,那就好了

我在网格中显示了几个组件(来自同一类型B)。。。似乎我对管理会话有意见


如果我有多个组件,那么它们都将共享同一个会话?

看起来您没有正确链接它们。像一个普通的承诺一样把他们拴起来

试着像这样把它们拴起来

ApiService.get(...)
  .then((response) => {
    return ApiService.get(...); // using response.data
  })
  .then((response) => {
            this.setState({
                configTables: response
            }
        )
  });

不要嵌套它们,而是执行第一个请求的第一个
。然后执行第一个请求的
。然后返回该承诺,这样第二个请求将有一个
。然后执行第二个请求的

不,相同:~500(内部服务器错误)!但正如我前面提到的,如果我停止使用调试器,一行一行地进行调试,它就会通过!!!我意识到问题比这更深,当我有多个组件时就会发生。。。我正在网格中显示一个组件s(来自同一类型B)。。。似乎我在管理会话方面有问题!如果我在同一个会话中并且有多个组件,那么它们都将共享同一个会话?!