Github user benkeen commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/475#discussion_r38335518
--- Diff: app/addons/components/react-components.react.jsx ---
@@ -385,18 +495,145 @@ function (app, FauxtonAPI, React, Components, ace,
beautifyHelper) {
return this;
},
+ getLine: function (lineNum) {
+ return this.editor.session.getLine(lineNum);
+ },
+
+ getSelectionStart: function () {
+ return this.editor.getSelectionRange().start;
+ },
+
+ getSelectionEnd: function () {
+ return this.editor.getSelectionRange().end;
+ },
+
+ getRowHeight: function () {
+ return this.editor.renderer.layerConfig.lineHeight;
+ },
+
+ isRowExpanded: function (row) {
+ return !this.editor.getSession().isRowFolded(row);
+ },
+
+ documentToScreenRow: function (row) {
+ return this.editor.getSession().documentToScreenRow(row, 0);
+ },
+
+ replaceCurrentLine: function (replacement) {
+ this.editor.getSelection().selectLine();
+ this.editor.insert(replacement);
+ this.editor.getSelection().moveCursorUp();
+ },
+
+ render: function () {
+ return (
+ <div>
+ <div ref="ace" className="js-editor" id={this.props.id}></div>
+ <button ref="stringEditIcon" className="btn string-edit"
title="Edit string" disabled={!this.state.stringEditIconVisible}
+ style={this.state.stringEditIconStyle}
onClick={this.openStringEditModal}>
+ <i className="icon icon-edit"></i>
+ </button>
+ <StringEditModal
+ ref="stringEditModal"
+ visible={this.state.stringEditModalVisible}
+ onSave={this.saveStringEditModal}
+ onClose={this.closeStringEditModal} />
--- End diff --
Hmm, I'm on the fence on this one. In many cases (like one or two instances
you mentioned above) I agree, but the nice thing about callbacks is that dumb
components like StringEditModal don't need to maintain their own state and can
be used anyway very, very easily (just pass in props). I think it's simpler,
less code, and easier to re-use the component.
I don't think passing callbacks in of itself is "un-Reacty" or necessarily
a bad approach.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---