'./App' does not contain a default export appears

Asked 2 years ago, Updated 2 years ago, 339 views

US>Error Contents
Unexpected token, expected", "(127:0)

I am unable to compile due to this error.This may be a rudimentary question, but I appreciate your cooperation.

import Amplify, {Storage} from 'aws-amplify';
import {AmplifyAuthenticator, AmplifySignUp, AmplifySignOut} from '@aws-amplify/ui-react';
import {AuthState, onAuthUISstateChange} from '@aws-amplify/ui-components';
import awscconfig from './aws-exports';
import AWS from 'aws-sdk';
import {Bucket} from '@aws-sdk/client-s3';

Amplify.configure(awscconfig);

constApp=()=>{
    const [name, setName] = useState('')
    const [file, setFile] = useState(')
    const [response, setResponse] = useState(')

    const [authState, setAuthState] = React.useState();
    const [user, setUser] = React.useState();
    const[s3Objects, setS3Objects] = useState([]);

    React.useEffect(()=>{
      AWS.config.update({
        region: 'ap-northeast-1',
        accessKeyId: 'Key',
        secretAccessKey: 'Key'})
      consts3 = new AWS.S3 ({apiVersion:'2006-03-01'});
      var bucketParams = {
        Bucket: 'Bucket',
        };
    s3.listObjects(bucketParams, function(err,data){
      if(err){
        console.log("Error", error);
      } else{
        Call setS3 Objects (data.Contents); // setS3 Objects to render again.
      }
        return onAuthUISstateChange((nextAuthState,authData)=>{
            setAuthState(nextAuthState);
            setUser(authData)
        });
    }, []);

    constonChange=(e)=>{
    e.preventDefault()
    if(e.target.files[0]!==null){
      setFile(e.target.files[0])
      setName(e.target.files[0].name)
    }
  }
  constonSubmit=(e)=>{
    e.preventDefault()
    if(file){
      Storage.put(name,file,{
        /* level: 'protected', */
        contentType: file.type,
      })
        .then(result)=>{
          console.log(result)
          setResponse(`Success uploading file:${name}!`)
        })
        .then()=>{
          document.getElementById('file-input').value=null
          setFile(null)
        })
        .catch(err)=>{
          console.log(err)
          setResponse(`Can't upload file:${err}`)
        })
    } else{
      setResponse(`Files needed!`)
    }
  }
  
s3.listObjects(bucketParams, function(err,data){
if(err){
  console.log("Error", error);
} else{
  for(leti=0;i<data.Contents.length;i++){
    list1.push(data.Contents[i]);
    console.log(data.Contents[i].Key); // This is also output to the console
  }
  for (vard in list 1) {
    console.log (list1[d].Key); // This is also output to the console
  } 
}
})
    return authState === AuthState.SignedIn&user?(
      <div className="App">
          <div>Hello, {user.username}</div>
          <div className='video-uploader'>
            <form onSubmit={(e)=>onSubmit(e)}>
            <p>
              <label className='select-label'>Select video:</label>
            </p>
            <p>
              <input
                className = 'video-input'
                type = 'file'
                id = 'file-input'
                accept='image/*, video/*'
                onChange={(e)=>onChange(e)}
              />
            </p>
            <button type='submit'className='btn'>Submit</button>
          </form>
          <div><div>
      {s3Objects.map((o)=><p>{o.Key}</p>)}
    </div>
          </div>
          
          </div>
            
          <AmplifySignOut/>
      </div>
    ) : (
      <AmplifyAuthenticator>
        <AmplifySignUp
          slot = "sign-up"
          formFields = {[
            { type: "username"},
            { type: "password",
            { type: "email"}
          ]}
        />
      </AmplifyAuthenticator>
  );
}

export default App;``


It was resolved by the comments.

reactjs

2022-09-30 21:59

1 Answers

Compilation error due to common error.Resolved. Thank you.


2022-09-30 21:59

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.