reactjs - 无法从“node_modules\react-simple-chatbot”解析“styled-components”
问题描述
我正在尝试使用 expo cli 运行我的反应应用程序,并在构建 bundle.js 时出现以下错误。
以下是我的 App.js:
import React, { Component } from 'react';
import ChatBot from 'react-simple-chatbot';
let withTextToSpeech = [
{
id: '1',
component: <TextToSpeech msg="Hi" />,
trigger: '2',
},
{
id: '2',
user: true,
trigger: '3',
},
{
id: '3',
component: <TextToSpeech msg='What is your name?' />,
trigger: '4',
},
{
id: '4',
user: true,
trigger: '5',
},
{
id: '5',
component: <TextToSpeech msg = 'Nice to meet you!' />,
trigger: 6,
},
{
id: '6',
component: <TextToSpeech msg='How can i help you?' />,
trigger: 'search',
},
{
id: 'search',
user: true,
trigger: '7',
}
]
let withoutTextToSpeech = [
{
id: '1',
message: 'hi',
trigger: '2',
},
{
id: '2',
user: true,
trigger: '3',
},
{
id: '3',
message: 'What is your name?',
trigger: '4',
},
{
id: '4',
user: true,
trigger: '5',
},
{
id: '5',
message: 'Hi {previousValue}, nice to meet you!',
trigger: 6,
},
{
id: '6',
message: 'How can i help you?',
trigger: 'search',
},
{
id: 'search',
user: true,
trigger: '7',
}
]
class App extends Component {
constructor( props ){
super( props )
this.state= {
textToSpeech: true,
steps : withTextToSpeech,
sessionId: sessionId
}
withTextToSpeech.push(ChatMessageElement)
withoutTextToSpeech.push(ChatMessageElement)
}
render() {
console.log(this.state.textToSpeech)
return (
<div className="App">
<ChatBot
headerTitle="ChatBot"
recognitionEnable={true}
steps={this.state.textToSpeech ? withTextToSpeech : withoutTextToSpeech}
/>
</div>
);
}
}
export default App;
帮助将不胜感激。
解决方案
yarn add styled-components
import styled from 'styled-components'
推荐阅读
- java - 对象和基元之间的性能和设计差异
- javascript - 如何在javascript中添加触摸事件(屏幕上的右、左和下)?
- c# - 在 Razor 视图中使用时找不到命名空间
- elasticsearch - 标题文本的弹性搜索自动完成
- logging - 我们应该登录同一个数据库还是单独的数据库
- laravel - 在 gitlab-ci 期间无法在 docker 中启动 MySQL 服务
- mysql - 使用通配符在两列中查找 MySQL 近似重复项
- python - 分解 with 语句
- azure - 无法将 docker 映像从 azure 注册表托管到 azure 批处理
- javascript - JointJS 端口不起作用