Привет. Я пытаюсь создать экземпляр фотографии профиля в ответ с помощью паспорта Facebook, которого я не знаю. если я правильно получаю файл Json, а затем правильно сопоставляю его с моим компонентом.
Я использовал это в качестве ссылки https://www.storyblok.com/tp/react-dynamic-component-from-json
Я сейчас работаю в http://www.passportjs.org
, похоже, мой блок по какой-то причине не экспортируется. Яне совсем уверен, что это
файл, над которым я работаю, это https://github.com/Blummer92/learning_react/blob/master/src/passport.js
Header.js
import UserProfile from '../../data/models/UserProfile';
import * as user from 'passport-facebook';
function ProfileDetais() {
// Try to read user info, although it might not have loaded yet
// eslint-disable-next-line no-use-before-define
const user = UserProfile.userId.atributes.id(...user).profile(...user).picture;
return (ProfileDetail (block))} />);}}
ProfilePhoto.js
import React from 'react';
// eslint-disable-next-line no-unused-vars
const ProfilePhoto = () => {};
const Components = {
profilePhoto: ProfilePhoto,
};
export default block => {
// component does exist
if (typeof Components[block.component] !== 'undefined') {
return React.createElement(Components[block.component], {
key: block.user,
block,
});
}
};
return React.createElement(
() => <div>The component {block.component} has not been created yet.</div>,
{ key: block.user },
);
Ошибки
SyntaxError: Cannot use import statement outside a module
at Module._compile (internal/modules/cjs/loader.js:892:18)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)
at internal/main/run_main_module.js:17:11
/Users/zachary/WebstormProjects/MyApp/src/components/Header/Header.js
24:9 error 'user' is already declared in the upper scope no-shadow
43:12 error Insert `·` prettier/prettier
/Users/zachary/WebstormProjects/MyApp/src/components/Header/ProfilePhoto.js
2:8 error 'UserProfile' is defined but never used no-unused-vars
10:22 error Expected to return a value at the end of arrow function consistent-return
20:29 error 'block' is not defined no-undef
21:10 error 'block' is not defined no-undef