2017-02-17 9 views
1

インポートスクリプトのエラーが表示されています。つまり、何かを正しくインポートしたりエクスポートしたりしていないということです。私はそれをimport { getPath } from '~/redux/modules/camera'行に絞り込んだ。しかし、なぜ私はエラーが発生するのか分かりません。私はdispatchへのアクセス権を持っているので、getPath関数をインポートします。私は何をすべきか?ありがとう! ネイティブのインポートに失敗しましたエラー

import React, { PropTypes, Component } from 'react'; 
import { 
    Dimensions, 
    StyleSheet, 
    Text, 
    TouchableHighlight, 
    View 
} from 'react-native'; 
import Camera from 'react-native-camera' 
import { connect } from 'react-redux' 
import { getPath } from '~/redux/modules/camera' 


class NimbusCamera extends Component { 
    static propTypes = { 
    navigator: PropTypes.object.isRequired, 
    dispatch: PropTypes.func.isRequired, 
    } 
    state = { 
    camera: { 
     aspect: Camera.constants.Aspect.fill, 
     captureTarget: Camera.constants.CaptureTarget.disk, 
     type: Camera.constants.Type.front, 
     orientation: Camera.constants.Orientation.auto, 
     flashMode: Camera.constants.FlashMode.auto, 
    } 
    isRecording: false, 
    timeLeft: 30, 
    limitReached: false 
    } 
    render() { 
    console.log(this.props) 
    return (
     <View style={styles.container}> 
     <Camera 
      ref={(cam) => { 
      this.camera = cam; 
      }} 
      style={styles.preview} 
      aspect={this.state.camera.aspect} 
      type={this.state.camera.type} 
      captureTarget={this.state.camera.captureTarget} 
      captureAudio={true} 
      flashMode={this.state.camera.flashMode} 
      > 
      <Text style={styles.capture} onPress={this.startRecording.bind(this)}>[CAPTURE]</Text> 
      <Text style={styles.capture} onPress={this.stopRecording.bind(this)}>[STOP_RECORDING]</Text> 
     </Camera> 
     </View> 
    ); 
    } 
    startRecording =() => { 
    if (this.camera) { 
     this.camera.capture({mode: Camera.constants.CaptureMode.video}) 
      .then((data) => console.log(data)) 
      .catch(err => console.error(err)); 
     this.setState({ 
     isRecording: true 
     }); 
     let timerId = setInterval(countdown, 1000); 
     function countdown() { 
     if (this.state.timeLeft === 0) { 
      clearTimeout(timerId); 
      this.setState({isRecording: false}) 
     } else { 
      this.setState({timeLeft: this.state.timeLeft--}) 
     } 
     } 
    } 
    } 

    stopRecording =() => { 
    if (this.camera) { 
     this.camera.stopCapture(); 
     this.setState({ 
     isRecording: false 
     }); 
    } 
    } 
} 

export default connect()(NimbusCamera) 

const styles = StyleSheet.create({ 
    container: { 
    flex: 1 
    }, 
    preview: { 
    flex: 1, 
    justifyContent: 'flex-end', 
    alignItems: 'center', 
    height: Dimensions.get('window').height, 
    width: Dimensions.get('window').width 
    }, 
    capture: { 
    flex: 0, 
    backgroundColor: '#fff', 
    borderRadius: 5, 
    color: '#000', 
    padding: 10, 
    margin: 40 
    } 
}); 

enter image description here

は、ここに私のReduxのカメラモジュールです。

const GET_PATH = 'GET_PATH' 
const CLEAR_PATH = 'CLEAR_PATH' 

initialState = { 
    videoPath: '' 
} 

export function getPath (path) { 
    return { 
     type: GET_PATH, 
     path 
    } 
} 

export function clearPath() { 
    return { 
     type: CLEAR_PATH 
    } 
} 

export default function camera (state = initialState, action) { 
    switch (action.type) { 
     case GET_PATH : 
      return { 
       ...state, 
       videoPath: action.path 
      } 
     case CLEAR_PATH : 
      return { 
       ...state, 
       videoPath: '' 
      } 
     default : 
      return state 
    } 
} 

答えて

0

あなたのpackagerコンソールにログインしていますか?通常、はるかに詳細なエラー情報を表示します。

+0

私の場合、時々私はリモートからデバッグを停止し、さらに、赤い画面でより有用な別のエラー情報を表示します。 – EricHua23

+0

ありがとう!問題を引き起こしているがなぜその理由がわからない 'import {getPath}〜〜/ redux/modules/camera'に絞っています。私はそれを正しく輸出していると私は信じています。私は質問を更新しました。 – maxwellgover

+0

〜〜/ redux/modules/cameraを絶対パスに変更してみてください。 – EricHua23

-1

これらのポップアップのようなエラーは、コードに誤字を入れたときにも発生します。モジュールを正しくインポートすることはできません。最初にタイプミスのコードを確認してください:)

+0

ねえ。私はエラーを引き起こしているインポートを1つに絞っていますが、それでも理由はわかりません。私は質問を更新しました。 – maxwellgover

+0

@maxwellgoverおそらく '〜/ redux/modules/camera'を相対表記を使ってパスに変更してみてください。カメラの場所に応じて './redux/modules/camera'または '../redux/modules/camera' – nehvaleem

+0

キャッシュをリセットしたところで動作します。私は10分毎にそれをやっているように感じる。 – maxwellgover

関連する問題