Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/161.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 反应分享。抛出错误类型错误:超级表达式必须为null或函数,在require中使用时不能未定义_Reactjs_Webpack_Babeljs - Fatal编程技术网

Reactjs 反应分享。抛出错误类型错误:超级表达式必须为null或函数,在require中使用时不能未定义

Reactjs 反应分享。抛出错误类型错误:超级表达式必须为null或函数,在require中使用时不能未定义,reactjs,webpack,babeljs,Reactjs,Webpack,Babeljs,我是ReactJs新手,正在努力学习。我安装了一个react共享包。由于我试图编辑其他人的代码,我无法导入该软件包,因为我相信是webpack。每次我尝试导入一个包时,我都会收到一个错误,说导入应该始终位于脚本的顶部。我尝试使用require,但在控制台中出现此错误 TypeError: Super expression must either be null or a function, not undefined 我的代码如下所示: "use strict"; require('./..

我是ReactJs新手,正在努力学习。我安装了一个react共享包。由于我试图编辑其他人的代码,我无法导入该软件包,因为我相信是webpack。每次我尝试导入一个包时,我都会收到一个错误,说导入应该始终位于脚本的顶部。我尝试使用require,但在控制台中出现此错误

TypeError: Super expression must either be null or a function, not undefined
我的代码如下所示:

"use strict";

require('./../../../assets/styles/components/thread.less');


var reactShare = require('react-share');
var React = require('react');
var ReactDOM = require('react-dom');
var Fluxxor = require('fluxxor');
var _ = require("lodash");

var FluxMixin = Fluxxor.FluxMixin(React);
var StoreWatchMixin = Fluxxor.StoreWatchMixin;

var routerShape = require('react-router').routerShape;
var MicroAudioViews = require('./../../constants/MicroAudioViews');
var AudioModes = require("./../../constants/AudioModes");
var i18n = require("i18next-client");

//components
var AudioVisualizer = require('../elements/AudioVisualizer');
var ReviewOverlay = require('../elements/ReviewOverlay');
var ReviewShare = require('../elements/ReviewShare');
var Menu = require('../elements/Menu');
我必须使用
反应共享

<FacebookShareButton url={shareLink} quote={title} className="social-media-icon">
  <FacebookIcon size={32} round />
 </FacebookShareButton>` 

` 
组件在facebook上共享共享链接

这里是完整的代码

/*import {
    FacebookShareButton,
    GooglePlusShareButton,
    TwitterShareButton,
    WhatsappShareButton,

    FacebookIcon,
    TwitterIcon,
    WhatsappIcon

} from 'react-share';*/

"use strict";

require('./../../../assets/styles/components/thread.less');


var reactShare = require('react-share');
var React = require('react');
var ReactDOM = require('react-dom');
var Fluxxor = require('fluxxor');
var _ = require("lodash");

var FluxMixin = Fluxxor.FluxMixin(React);
var StoreWatchMixin = Fluxxor.StoreWatchMixin;

var routerShape = require('react-router').routerShape;
var MicroAudioViews = require('./../../constants/MicroAudioViews');
var AudioModes = require("./../../constants/AudioModes");
var i18n = require("i18next-client");

//components
var AudioVisualizer = require('../elements/AudioVisualizer');
var ReviewOverlay = require('../elements/ReviewOverlay');
var ReviewShare = require('../elements/ReviewShare');
var Menu = require('../elements/Menu');

var Review = React.createClass({
    mixins:[    
        FluxMixin,
        StoreWatchMixin("ThreadStore", "RecordStore", "ReviewStore", "ApplicationStore", "SyncStore", "DemoStore", "ShareStore")
    ],

    contextTypes: {
        router: routerShape.isRequired
    },

    /* react interface*/
    getInitialState: function() {
        var selectedThreads = [];
        var shareType = 'thread';
        if(this.props.location.state && this.props.location.state.type == "thread") {
            selectedThreads.push(this.props.location.state.threadId);
        } else if(this.props.location.state && this.props.location.state.type == "share") {
            shareType = 'facebook';
        } else if (this.props.location.state && this.props.location.state.type == 'sharereply') {
            shareType = 'sharereply';
        }
        return {
            threadUserId: this.props.params.id,
            activeShareType: shareType,
            selectedThreads: selectedThreads
        };
    },

    getStateFromFlux: function() {
        var flux = this.getFlux();
        var recordStoreState = flux.store('RecordStore').getState();
        var threadStoreState = flux.store('ThreadStore').getState();
        var appStoreState = flux.store('ApplicationStore').getState();
        var reviewStoreState = flux.store('ReviewStore').getState();
        var shareStoreState = flux.store('ShareStore').getState();
        var demoState = flux.store('DemoStore').getState();

        var activeRecord = recordStoreState.activeRecord || null;
        var activeThread = threadStoreState.activeThread;
        var activeRecordUser = null;

        var authenticatedUser = appStoreState.demoMode? demoState.user : appStoreState.user;
        var state = {
            demoMode: appStoreState.demoMode,
            playing: recordStoreState.playing,
            recording: recordStoreState.recording,
            activeThread: activeThread,
            threads: threadStoreState.threads,
            authenticatedUser: authenticatedUser,
            activeRecord: activeRecord,
            activeShareUser: shareStoreState.user,
            shareId: shareStoreState.shareId
        };
        return state;

    },

    render: function() {
        var threadClass = "thread";
        var fbClass = "facebook";
        var explanationText, usageContent;
        var finishButtonClass = 'finish-button';
        if(this.state.activeShareType == "thread") {
            threadClass += ' active';
            explanationText = i18n.t('content:review.reviewDoneExpl', {
                count: this.state.selectedThreads.length,
                context: this.state.selectedThreads.length == 0 ? 'doselect' :  undefined
            });
            finishButtonClass += this.state.selectedThreads.length == 0 ? ' inactive' :  '';

            var threadCards = [];
            var self = this;

            _.each(this.state.threads, function(thread){
                var threadUser = thread.user;
                var threadUserPicture = threadUser.pictures[0].source;
                var userName = threadUser.firstName + ' ' + threadUser.lastName;
                var styleProps = {
                    backgroundImage :  threadUserPicture ? 'url(' + threadUserPicture + ')': 'none'
                };
                var cls = "thread card" + (self.state.selectedThreads.indexOf(thread.id) != -1? " selected" : "");
                    threadCards.push(<div key={thread.id} className={cls} onClick={self.onThreadCardSelected} data-thread-id={thread.id}>
                            <div className='pic' style={styleProps}></div>
                            <div className='name'>{userName}</div>
                            <div className='checked micro-audio-icon-check'></div>
                        </div>);
            });


            //if thread cards array is null then we are displaying the required text
            if(threadCards.length==0){
                var text= "Du hast noch keine Freunde in audiyoh hinzugefugt (gehe dafur zur Suche).";

            //displaying the content
            usageContent = (
                <div className="usage-target-container">
                    <p className="chat-text">{text} <br/>Uber <img className="share-icon" src={require('./../../../assets/images/share-active.png')} /> Teilen kannst du deine Aufnahme in aderen Kanale teilen.</p>
                </div>);

            //displaying the button
            var finishContainer = <div className="finish-container">
                                            <div    className={finishButtonClass} >Fertige</div>
                                            <div    className="finish-text"><p className="chat-underbtn-text">Mindestens <b> ein Gesprach <br/> wahlen,</b> dem die Aufnahme <br/> hinzugefugt werden soll</p></div>
                                        </div>;             
            }else{
                usageContent = (
                    <div className="usage-target-container">
                        {threadCards}
                    </div>);    
            }

        } else {
            fbClass += ' active';
            finishButtonClass += ' facebook';
            explanationText = i18n.t('content:review.facebookExplanation');
            //displaying the input box with the link and copy button
            console.log("THe shareStoreState is " + this.state.shareId);

            //the shareId is generate asynchroneously, so this.state.shareId can be null
            if(typeof this.state.shareId === "string") {
                //the link can be created like this:
                var shareLink = window.location.origin + '/shared/' + this.state.shareId;
            }

            var usageContent = (
                    <div className="usage-target-container">
                        <div className="socialLinkContainer">
                            <p> Link zum Teilen </p>
                            <input className="copylink" type="text" value={shareLink} id="shareLink" /><br/>
                            <input className="copybtn" type="button" onClick={this.copytoclipboard} value="Link kopieren" /> 
                        </div>
                    </div>);

            var finishContainer = <div className="finish-container">
                                    <div className="social-media">
                                        /*<a href="" onClick=""><img className="social-media-icon" src={require('./../../../assets/images/facebook.png')} /></a>*/
                                        <FacebookShareButton
                                            url={shareLink}
                                            quote={title}
                                            className="social-media-icon">
                                            <FacebookIcon
                                              size={32}
                                              round />
                                          </FacebookShareButton>

                                        <a href="" onClick=""><img className="social-media-icon" src={require('./../../../assets/images/whatsapp.png')} /></a>
                                        <a href="" onClick=""><img className="social-media-icon" src={require('./../../../assets/images/twitter.png')} /></a>
                                        <a href="" onClick=""><img className="social-media-icon" src={require('./../../../assets/images/instagram.png')} /></a>
                                    </div>

                                </div>;
        }
        var targetSwitchElements = [
            <div title={i18n.t('content:review.sharethread')} 
                key="thread" 
                className={threadClass} 
                onClick={this.activateThreadShareType}><span>audiyoh-chat</span></div>,<br/>,
            <div title={i18n.t('content:review.sharefb')} 
                key="facebook" 
                className={fbClass} 
                onClick={this.activateFBShareType}><span>Teilen</span></div>
        ];




        //we either want to save a profile record a share response, so we dont need the fb/thread  switch and thread cards
        if(this.props.location.state && ["profile", "sharereply"].indexOf(this.props.location.state.type) != -1) {
            var buttonText = i18n.t('content:review.profile');
            if(this.props.location.state.type == "sharereply"){
             buttonText = i18n.t('content:review.share', {name: this.state.activeShareUser.firstName});
            }
            targetSwitchElements = <div className="profile-record" onClick={this.onFinishRecord}>{buttonText}</div>;
            usageContent = null;
            finishContainer = null;
        }


        return (
            <div className="ma-reviewing">
                <div className="review-controls">
                <div className="row">
                    <div className="col-3">
                        <a title={i18n.t('content:review.delete')} className="delete" onClick={this.deleteRecording}></a>
                        <a title={i18n.t('content:review.redo')} className="record" onClick={this.onRecordButtonClick}></a>
                    </div>

                    <div className="col-6">
                        <div className="review-container">
                            <ReviewOverlay 
                                activeRecordUser={this.state.authenticatedUser} 
                                record={this.state.activeRecord} 
                            />
                        </div>
                    </div>
                    {finishContainer}
                    <div className="col-3">
                        <div className="target-switch">
                            <p>Weiter mit der Aufnahme</p>
                            {targetSwitchElements}
                        </div>
                    </div>
                </div>
                </div>
                <div className="upper" ref="upper">
                    <Menu location={this.props.location} />
                    <div className="menu">
                    </div>
                </div>
                <div className="upperguard" ref="upperguard"></div>
                <div className="lower" ref="lower">
                    <div className="sizing-wrapper">
                        {usageContent}
                    </div>
                </div>
            </div>
        );
    },

    deleteRecording: function(e) {
        e.preventDefault();
        if(this.props.location && this.props.location.state.userId) {
            this.context.router.push({
                pathname: "/thread/" + this.props.location.state.userId,
                state: this.props.location.state
            });
        } 
        else {
            this.context.router.push({
                pathname: "/profile",
                state: this.props.location.state
            });
        }
    },

    onRecordButtonClick: function(e) {
        e.preventDefault();
        this.context.router.push({
            pathname: "/record",
            state: this.props.location.state
        });
    },

    onThreadCardSelected: function(syntheticEvent, reactId, e) {
        var target = syntheticEvent.target.parentNode;
        var threadId = target.getAttribute("data-thread-id");
        var idx = this.state.selectedThreads.indexOf(threadId);

        if(idx != -1) {
            this.state.selectedThreads.splice(idx, 1);
            this.setState({
                selectedThreads: [].concat(this.state.selectedThreads)
            });
        }
        else {
            this.setState({
                selectedThreads: [threadId].concat(this.state.selectedThreads)
            });
        }
    },

    activateThreadShareType: function() {
        if(this.state.activeShareType == "thread") {
            return;
        }

        this.setState({
            activeShareType: 'thread'
        });
    },
    activateFBShareType: function() {
        if(this.state.activeShareType == "facebook") {
            return;
        } 

        this.setState({
            activeShareType: 'facebook'
        });

        //this will store the record and generate a shareId
        this.getFlux().actions.record.local.saveRecording({
            type: "share"
        });
        /*var state1 = this.context.router.push({
            pathname: '/review',
            state: {
                type: "profile",
                role: "main"
            }
        });*/

        //console.log("the state1    is " + state1);
        //this.getFlux().actions.record.local.saveRecording(state1);
    },

    copytoclipboard: function(){

          var copyText = document.getElementById("shareLink");
          copyText.select();
          document.execCommand("copy");
          console.log("Copied the text: " + copyText.value);

    },

    onFinishRecord: function(e) {
        if(e.target.classList.contains('inactive')) {
            return;
        } 

        if(this.props.location.state && ["profile", "sharereply"].indexOf(this.props.location.state.type) != -1) {
            console.log(this.props.location.state);
            this.getFlux().actions.record.local.saveRecording(this.props.location.state);
        }
        else if(this.state.activeShareType == "facebook") {
            this.getFlux().actions.record.local.saveRecording({
                type: "share"
            });
        }
        else {
            var data = {
                type: "thread",
                threadIds: this.state.selectedThreads
            };

            //we started recording from a thread, so we pass the userId to be able to return to this thread
            //after saving
            if(this.props.location.state && this.props.location.state.type == "thread") {
                data.userId = this.props.location.state.userId;
            }

            this.getFlux().actions.record.local.saveRecording(data);
        }
    }
});

module.exports = Review;
/*导入{
FacebookShareButton,
GooglePlusShareButton,
推特共享按钮,
什么是哈雷按钮,
FacebookIcon,
推特图标,
WhatsappIcon
}从‘反应分享’*/
“严格使用”;
需要('./../../../../assets/styles/components/thread.less');
var react-share=要求('react-share');
var React=要求('React');
var ReactDOM=require('react-dom');
var Fluxxor=require('Fluxxor');
var=要求(“lodash”);
var FluxMixin=Fluxxor.FluxMixin(反应);
var StoreWatchMixin=Fluxxor.StoreWatchMixin;
var routerShape=require('react-router')。routerShape;
var MicroAudioViews=require('./../../../constants/MicroAudioViews');
var AudioModes=需要(“../../../../constants/AudioModes”);
var i18n=需要(“i18next client”);
//组成部分
var AudioVisualizer=require(“../elements/AudioVisualizer”);
var ReviewOverlay=require(“../elements/ReviewOverlay”);
var ReviewShare=require(“../elements/ReviewShare”);
var Menu=require('../elements/Menu');
var Review=React.createClass({
混合物:[
氟美辛,
StoreWatchMixin(“ThreadStore”、“RecordStore”、“ReviewStore”、“ApplicationStore”、“SyncStore”、“DemoStore”、“ShareStore”)
],
上下文类型:{
路由器:routerShape.isRequired
},
/*反应界面*/
getInitialState:函数(){
var selectedThreads=[];
var shareType='thread';
if(this.props.location.state&&this.props.location.state.type==“线程”){
selectedThreads.push(this.props.location.state.threadId);
}else if(this.props.location.state&&this.props.location.state.type==“共享”){
shareType='facebook';
}else if(this.props.location.state&&this.props.location.state.type==“sharereply”){
shareType='sharereply';
}
返回{
threadUserId:this.props.params.id,
activeShareType:shareType,
selectedThreads:selectedThreads
};
},
getStateFromFlux:function(){
var flux=this.getFlux();
var recordStoreState=flux.store('RecordStore').getState();
var threadStoreState=flux.store('ThreadStore').getState();
var appStoreState=flux.store('ApplicationStore').getState();
var reviewStoreState=flux.store('ReviewStore').getState();
var shareStoreState=flux.store('ShareStore').getState();
var demoState=flux.store('DemoStore').getState();
var-activeRecord=recordStoreState.activeRecord | | null;
var activeThread=threadStoreState.activeThread;
var activeRecordUser=null;
var authenticatedUser=appStoreState.demoMode?demoState.user:appStoreState.user;
变量状态={
demoMode:appStoreState.demoMode,
播放:recordStoreState.playing,
录制:recordStoreState.recording,
activeThread:activeThread,
线程:threadStoreState.threads,
authenticatedUser:authenticatedUser,
activeRecord:activeRecord,
activeShareUser:shareStoreState.user,
shareId:shareStoreState.shareId
};
返回状态;
},
render:function(){
var threadClass=“thread”;
var fbClass=“facebook”;
变量解释文本、用法内容;
var finishButtonClass='finish button';
if(this.state.activeShareType==“thread”){
threadClass+=‘活动’;
explanationText=i18n.t('content:review.reviewDoneExpl'{
计数:this.state.selectedThreads.length,
上下文:this.state.selectedThreads.length==0?'doselect':未定义
});
finishButtonClass+=this.state.selectedThreads.length==0?'inactive':'';
var-threadCards=[];
var self=这个;
_.each(this.state.threads,函数(thread){
var threadUser=thread.user;
var threadUserPicture=threadUser.pictures[0]。源;
var userName=threadUser.firstName+“”+threadUser.lastName;
var styleProps={
背景图片:threadUserPicture?'url('+threadUserPicture+'):'none'
};
var cls=“thread card”+(self.state.selectedThreads.indexOf(thread.id)!=-1?“selected”:“”;
推(
{userName}
);
});
//如果线程卡数组为空,则显示所需的文本
if(螺纹卡长度==0){
var text=“你在奥迪奥·欣祖格富格(gehe dafur zur Suche)中没有基恩·弗伦德(keine Freunde)。”;
//显示内容
usageContent=(

{text}
在aderen Kanale Teilen的Uber Teilen kannst du deine Aufnahme

); //显示按钮 var finishContainer= 施肥

我的朋友们都在这里

<FacebookShareButton url={shareLink} quote={title} className="social-media-icon">
  <FacebookIcon size={32} round />
 </FacebookShareButton>` 
var FacebookShareButton = require('react-share');