fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

String Ref in CalendarMonth.tsx

Open SudharsanSukumar opened this issue 7 years ago • 7 comments

Environment Information

  • Package version(s): 6.190.1
  • Browser and OS versions: (fill this out if relevant)

Please provide a reproduction of the bug in a codepen:

It seems that yarn linking causes the string refs to break with "Invariant Violation" errors from react.

Here's the more of the error message: Component DateEditor caught error Invariant Violation: Element ref was specified as a string (navigatedMonth) but no owner was set. This could happen for one of the following reasons:

  1. You may be adding a ref to a function component
  2. You may be adding a ref to a component that was not created inside a component's render method
  3. You have multiple copies of React loaded

Here are some similar GitHub issues I've found: https://github.com/intljusticemission/react-big-calendar/issues/968 https://github.com/uber/react-vis/issues/736

Actual behavior:

React throws an Invariant Violation when yarn linking and trying to render the monthPicker part of the Calendar component.

Expected behavior:

No throwing. I believe using React.createRef and putting that in CalendarMonth.tsx line 222 will fix this based on the related git issues I linked above.

Priorities and help requested:

Are you willing to submit a PR to fix? No

Requested priority: High

Products/sites affected: Microsoft Project

SudharsanSukumar avatar Sep 06 '19 16:09 SudharsanSukumar

@SudharsanSukumar, how do I repro this error? Is it at build time or run-time? Can you provide a code snippet or branch with instructions so I can make sure my fix resolves it.

Thanks!

KevinTCoughlin avatar Sep 06 '19 18:09 KevinTCoughlin

It's a runtime error. Unfortunately it requires a yarn link but here's a description:

  1. Have a child repo that renders the Calendar with isMonthPickerVisible set to true.
  2. In parent repo, use yarn link
  3. Build the parent repo and test rendering the child component which renders the Calendar with isMonthPickerVisible set to true.

SudharsanSukumar avatar Sep 06 '19 18:09 SudharsanSukumar

@SudharsanSukumar, I've raised a PR that once approved and merged we can cherry-pick into 6.x release. If you're able to try the changes locally to see if your run-time error is resolved, please do that and report back.

Thanks!

KevinTCoughlin avatar Sep 09 '19 17:09 KevinTCoughlin

:tada:This issue was addressed in #10393, which has now been successfully released as [email protected].:tada:

Handy links:

msft-github-bot avatar Sep 13 '19 12:09 msft-github-bot

@KevinTCoughlin what v6 version will this be released under?

SudharsanSukumar avatar Sep 15 '19 08:09 SudharsanSukumar

@KevinTCoughlin what v6 version will this be released under?

@SudharsanSukumar, once https://github.com/OfficeDev/office-ui-fabric-react/pull/10459 is merged it will publish overnight in next 6.x release.

KevinTCoughlin avatar Sep 16 '19 16:09 KevinTCoughlin

:tada:This issue was addressed in #10393, which has now been successfully released as [email protected].:tada:

Handy links:

msft-github-bot avatar Sep 17 '19 12:09 msft-github-bot