Skip to content

Commit cad25f2

Browse files
Merge pull request #27 from pgerlich/step-message-as-function
Allow step messages to be functions as well as strings
2 parents 9f3755d + e908855 commit cad25f2

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

dist/react-simple-chatbot.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/schemas/textSchema.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default [
66
},
77
{
88
key: 'message',
9-
types: ['string'],
9+
types: ['string', 'function'],
1010
required: true,
1111
},
1212
{

lib/steps/text/TextStep.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class TextStep extends Component {
4646
});
4747
}
4848

49+
// Account for message being a callback which returns a string
50+
message = (typeof message === 'function') ? message() : message;
4951
message = message.replace(/{previousValue}/g, previousValue);
5052

5153
return message;

0 commit comments

Comments
 (0)