React pubsub failed to subscribe for the first time

failed to subscribe to PubSub.subscribe for the first time, click back and click publish again, but the subscription was successful twice, and then it was normal after the third time.
but there is no problem with using Subject and Result instead of switch in app.jsx. A lot of advice. Thank you!

app.jsx
    <Switch>
        <Route path="/subject" component={Subject}/>
        <Route path="/result/" component={Result}/>
        <Redirect to="/subject"/>
    </Switch>
subject.jsx    
    handerSubmit = ()=>{
        PubSub.publish("out",outcome);
        this.props.history.push("/result")

    }
result.jsx        
    componentDidMount(){
        let subscr;
        new Promise((resolve,reject)=>{
            subscr = PubSub.subscribe("out",(msg,outcome)=>{
                console.log(1)
                //alert(outcome);
                arr  = [
                    outcome[4]+outcome[9]+outcome[13]+outcome[17]+outcome[23]+outcome[29],
                    outcome[2]+outcome[5]+outcome[12]+outcome[19]+outcome[21]+outcome[28],
                    outcome[1]+outcome[7]+outcome[14]+outcome[16]+outcome[24]+outcome[27],
                    outcome[0]+outcome[6]+outcome[10]+outcome[15]+outcome[20]+outcome[25],
                    outcome[3]+outcome[8]+outcome[11]+outcome[18]+outcome[22]+outcome[26]
                ];
                resolve(arr)
            })
        }).then(
            (result)=> {
                this.showCanvas(result)
            },

        );

    }
    componentWillUnmount(){
        PubSub.unsubscribe(this.subscr);
    }

problem description

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?


subject and result cannot be loaded at the same time.

in addition, your subscribe is written incorrectly. This.subscr does not point to the function returned by subscribe, so unsuscribe fails.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e44eed-44333.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e44eed-44333.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?