Better to return created reactElement.#213
Conversation
|
@DimaZab I've never seen that pattern. What's the use case? Jade? @alexfedoseev any opinion? |
|
@DimaZab Maybe push up small test repo demonstrating this? |
|
Also never seen that pattern. Use case will be nice. |
|
@justin808, @alexfedoseev https://github.com/DimaZab/example here is an example, see README. And if we look in react source code we will see that render method return created react element. render: function (nextElement, container, callback) {
return ReactMount._renderSubtreeIntoContainer(null, nextElement, container, callback);
} |
|
@DimaZab @justin808 It makes sense 👍 |
|
OK -- so no harm in doing this. Yikes, and yuck for mixing jQuery with React! 😄 |
|
@DimaZab can you please add a JS test for this. I think JS will be sufficient. rather than a full integration test. |
|
@justin808 I agree about jQuery and React but it's only for the first time. |
|
@justin808 I've try to write test for this method: render(name, props, domNodeId) {
const reactElement = createReactElement({ name, props, domNodeId });
return ReactDOM.render(reactElement, document.getElementById(domNodeId));
},But get an error: 'document is not defined'. So, can I use something like mock-browser (https://www.npmjs.com/package/mock-browser) or may be you know better way? |
|
@DimaZab Sure -- you'll need to use something like that. Thanks! |
1a624fa to
7e77cf9
Compare
|
@justin808 done =) |
There was a problem hiding this comment.
can we name this "actualElement" or "actualComponent"?
There was a problem hiding this comment.
@justin808 I think we should stick with the JSX testing convention, which is to leave it as actual
|
@DimaZab, I'd like to get the merged as soon as you complete the changes I've requested. Thanks. Reviewed 3 of 3 files at r1. Comments from the review on Reviewable.io |
b2e33b4 to
679ce31
Compare
|
@justin808 done |
|
Some additional small items. Reviewed 5 of 5 files at r2. docs/additional_reading/javascript_rendering.md, line 26 [r2] (raw file): node_package/src/ReactOnRails.js, line 31 [r2] (raw file): node_package/tests/ReactOnRails.test.js, line 24 [r1] (raw file): README.md, line 380 [r2] (raw file): Rails View Rendering from Inline JavaScript Comments from the review on Reviewable.io |
81e8884 to
386599a
Compare
|
Reviewed 5 of 6 files at r2. docs/additional_reading/rails_view_rendering_from_inline_javascript.md, line 7 [r3] (raw file): We should copy the jsdoc from the JS file. node_package/src/ReactOnRails.js, line 32 [r3] (raw file): Comments from the review on Reviewable.io |
|
@robwise Thank you) |
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7. - [Release notes](https://github.com/jbgutierrez/path-parse/releases) - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) --- updated-dependencies: - dependency-name: path-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7. - [Release notes](https://github.com/jbgutierrez/path-parse/releases) - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) --- updated-dependencies: - dependency-name: path-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
If I use only React component and I want to manually set state, maybe better to return rendered reactElement?