String Ref in CalendarMonth.tsx
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:
- You may be adding a ref to a function component
- You may be adding a ref to a component that was not created inside a component's render method
- 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, 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!
It's a runtime error. Unfortunately it requires a yarn link but here's a description:
- Have a child repo that renders the Calendar with isMonthPickerVisible set to true.
- In parent repo, use yarn link
- Build the parent repo and test rendering the child component which renders the Calendar with isMonthPickerVisible set to true.
@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!
:tada:This issue was addressed in #10393, which has now been successfully released as [email protected].:tada:
Handy links:
@KevinTCoughlin what v6 version will this be released under?
@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.
:tada:This issue was addressed in #10393, which has now been successfully released as [email protected].:tada:
Handy links: