Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v4] Enable strict mode #1709

Merged
merged 1 commit into from
Jun 24, 2019
Merged

[v4] Enable strict mode #1709

merged 1 commit into from
Jun 24, 2019

Conversation

AndrewMusgrave
Copy link
Member

@AndrewMusgrave AndrewMusgrave commented Jun 18, 2019

WHY are these changes introduced?

Fixes: #1709 - This will keep us on track in the future 馃

@BPScott BPScott temporarily deployed to polaris-react-pr-1709 June 18, 2019 22:05 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1709 June 18, 2019 22:47 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1709 June 18, 2019 22:49 Inactive
@AndrewMusgrave AndrewMusgrave added the 馃Skip Changelog Causes CI to ignore changelog update check. label Jun 18, 2019
@BPScott
Copy link
Member

BPScott commented Jun 18, 2019

Fixes #785

@@ -34,7 +34,7 @@ describe('<Header />', () => {
const warnSpy = jest.spyOn(console, 'warn');
mountWithAppProvider(<Header {...mockProps} icon="foo" />);

expect(warnSpy).toHaveBeenCalledTimes(1);
expect(warnSpy).toHaveBeenCalled();
Copy link
Member Author

Choose a reason for hiding this comment

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

React.StrictMode is causing a second render. I'm not sure why, but I don't think it's a huge deal.

Copy link
Member

Choose a reason for hiding this comment

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

It does that intentionally to try and make it side effects obvious as per https://reactjs.org/docs/strict-mode.html#detecting-unexpected-side-effects

Copy link
Member Author

Choose a reason for hiding this comment

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

Neat 馃槏

Screen Shot 2019-06-20 at 2 22 55 AM

@BPScott BPScott temporarily deployed to polaris-react-pr-1709 June 19, 2019 15:09 Inactive

beforeEach(() => {
consoleSpy = jest.spyOn(console, 'error');
consoleSpy.mockImplementation(() => {});
Copy link
Member Author

Choose a reason for hiding this comment

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

Silences the error

Copy link
Contributor

Choose a reason for hiding this comment

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

Which error is that?

Copy link
Member

Choose a reason for hiding this comment

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

The one at the bottom of this file around expect(consoleSpy).toHaveBeenCalledWith(. This mockImplementation makes it so the error we're deliberately causing does not get output to the console as we expect it to appear.

@AndrewMusgrave AndrewMusgrave marked this pull request as ready for review June 19, 2019 15:10
@AndrewMusgrave AndrewMusgrave added this to the v4.0.0 milestone Jun 19, 2019
@@ -66,7 +66,9 @@ export function addPlaygroundStory(playgroundModule) {
function AppProviderDecorator(story) {
return (
<div style={{padding: '8px'}}>
<AppProvider i18n={en}>{story()}</AppProvider>
<React.StrictMode>
Copy link
Member

Choose a reason for hiding this comment

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

Instead of setting this in the AppProviderDecorator I think we should add a new global decorator to make sure this applies to all stories. (Admittedly currently AppProvider ends up being applied to everything but at some point that might change if we want to pull in stories from places other than the readmes)

Can you revert this and then in .storybook/config.js under the addParameters call add:

const StrictModeDecorator = story => <React.StrictMode>{story()}</React.StrictMode>;
addDecorator(StrictModeDecorator);


beforeEach(() => {
consoleSpy = jest.spyOn(console, 'error');
consoleSpy.mockImplementation(() => {});
Copy link
Contributor

Choose a reason for hiding this comment

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

Which error is that?

Copy link
Member

@BPScott BPScott left a comment

Choose a reason for hiding this comment

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

Woo, this is a fantastic milestone!

@BPScott BPScott requested a deployment to polaris-react-pr-1709 June 24, 2019 15:33 Abandoned
@AndrewMusgrave AndrewMusgrave merged commit 6fb4a77 into version-4.0.0 Jun 24, 2019
@AndrewMusgrave AndrewMusgrave deleted the enable-strict-mode branch June 24, 2019 15:43
@AndrewMusgrave AndrewMusgrave temporarily deployed to alpha July 9, 2019 21:32 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
馃Skip Changelog Causes CI to ignore changelog update check.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants