Skip to content

Commit 68904af

Browse files
committed
change: remove lodash from ChatBot.jsx
1 parent a0c4ebf commit 68904af

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/ChatBot.jsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import _ from 'lodash';
21
import React, { Component } from 'react';
32
import PropTypes from 'prop-types';
43
import Random from 'random-id';
@@ -324,7 +323,10 @@ class ChatBot extends Component {
324323
this.props.handleEnd({ renderedSteps, steps, values });
325324
}
326325
}
327-
326+
isInputValueEmpty() {
327+
const { inputValue } = this.state;
328+
return Boolean(inputValue) && inputValue.length > 0;
329+
}
328330
isLastPosition(step) {
329331
const { renderedSteps } = this.state;
330332
const length = renderedSteps.length;
@@ -371,8 +373,8 @@ class ChatBot extends Component {
371373
}
372374

373375
handleSubmitButton() {
374-
const { inputValue, speaking, recognitionEnable } = this.state;
375-
if ((_.isEmpty(inputValue) || speaking) && recognitionEnable) {
376+
const { speaking, recognitionEnable } = this.state;
377+
if ((this.isInputValueEmpty() || speaking) && recognitionEnable) {
376378
this.recognition.speak();
377379
if (!speaking) {
378380
this.setState({ speaking: true });
@@ -565,7 +567,7 @@ class ChatBot extends Component {
565567
);
566568

567569
const icon =
568-
(_.isEmpty(inputValue) || speaking) && recognitionEnable ? <MicIcon /> : <SubmitIcon />;
570+
(this.isInputValueEmpty() || speaking) && recognitionEnable ? <MicIcon /> : <SubmitIcon />;
569571

570572
const inputPlaceholder = speaking
571573
? recognitionPlaceholder
@@ -603,7 +605,7 @@ class ChatBot extends Component {
603605
height={height}
604606
hideInput={currentStep.hideInput}
605607
>
606-
{_.map(renderedSteps, this.renderStep)}
608+
{Object.values(renderedSteps).map(this.renderStep)}
607609
</Content>
608610
<Footer className="rsc-footer" style={footerStyle}>
609611
{!currentStep.hideInput && (

0 commit comments

Comments
 (0)