Skip to content
This repository was archived by the owner on Jul 1, 2020. It is now read-only.

Replacing div with React Fragment#8

Open
krishnaglick wants to merge 3 commits into
zekchan:masterfrom
krishnaglick:patch-1
Open

Replacing div with React Fragment#8
krishnaglick wants to merge 3 commits into
zekchan:masterfrom
krishnaglick:patch-1

Conversation

@krishnaglick
Copy link
Copy Markdown

Using div means this affects the dom. This could have unintended consequences. Replacing it with React.Fragment (<> shorthand) removes that issue.

Using div means this affects the dom. This could have unintended consequences. Replacing it with React.Fragment (<> shorthand) removes that issue.
@@ -0,0 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Snapshots are a great way to enforce tests without manually writing out all the html in each test!

Comment thread src/client.test.js

expect(component.html()).toBe('<div></div>')
expect(component.html()).toBe(null)
expect(component.html()).toMatchSnapshot()
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it doesn't render the extra div, we now default to null. This is possibly a breaking change.

Comment thread src/client.test.js
)

expect(component.html()).toBe('<div><div>No errors! Context variable</div></div>')
expect(component.html()).toBe('<div>No errors! Context variable</div>')
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping these expectations to show things passing, but it'd be awesome to switch solely to snapshots.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant