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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TimeLineHeaders renders in the wrong position together with react-hot-loader #607

Closed
westn opened this issue Jul 2, 2019 · 6 comments
Closed

Comments

@westn
Copy link

westn commented Jul 2, 2019

Describe the bug
Using react-hot-loader together with a custom TimeLineHeader will cause the custom component to render under .rct-scroll instead of replacing the original .rct-header-root

To Reproduce

Use react-calendar-timeline inside a project with react-hot-loader (https://github.com/gaearon/react-hot-loader)

Create a TimeLine with a custom TimelineHeader, e.g., with the basic example.

import Timeline, {
  TimelineHeaders,
  SidebarHeader,
  DateHeader,
} from 'react-calendar-timeline';
import moment from 'moment';
...
<Timeline
            groups={groups}
            items={items}
            defaultTimeStart={moment().add(-12, 'hour')}
            defaultTimeEnd={moment().add(12, 'hour')}
          >
            <TimelineHeaders>
              <SidebarHeader>
                {({ getRootProps }) => {
                  return <div {...getRootProps()}>Left</div>;
                }}
              </SidebarHeader>
              <DateHeader unit="primaryHeader" />
              <DateHeader />
            </TimelineHeaders>
          </Timeline>

(I might be able to add a working example a bit later)

Expected behavior
Expect it to replace the custom header as intended.
From what I've found it seems to be related to this comparison:

if (child.type === TimelineHeaders) {

Something which already was discussed for other react-hot-loader issues in gaearon/react-hot-loader#304

Library Version
0.25.4

Desktop (please complete the following information):

  • OS: MacOS
  • Browse Chrome
  • Version 75

Additional context
It seems like it's somewhat related to react-hot-loader, but something that they don't seem willing to fix.

@westn
Copy link
Author

westn commented Jul 3, 2019

Here is a codesandbox for repro: https://codesandbox.io/s/react-hot-loader-o4sgz

@westn
Copy link
Author

westn commented Jul 5, 2019

An incorrect, but a functional solution to this is replacing the comparison with:

const a = child.type.prototype.constructor.displayName;
const b = _TimelineHeaders2.default.prototype.constructor.name;
if (a === b) {

thus using the name of the component.

@Ilaiwi
Copy link
Collaborator

Ilaiwi commented Jul 5, 2019

@westn please feel free to submit a PR make this work with rhr. Otherwise, I am not going to spend resources on this since it is not related to the library itself...

@Ilaiwi Ilaiwi closed this as completed Jul 5, 2019
@Ilaiwi
Copy link
Collaborator

Ilaiwi commented Sep 9, 2019

I am reopening this since now I am facing the same issue with a new codebase.

@Ilaiwi Ilaiwi reopened this Sep 9, 2019
@Ilaiwi
Copy link
Collaborator

Ilaiwi commented Sep 9, 2019

@westn tried your solution but no luck with this solution

This was referenced Sep 11, 2019
@Ilaiwi
Copy link
Collaborator

Ilaiwi commented Sep 11, 2019

released in 0.26.4

@Ilaiwi Ilaiwi closed this as completed Sep 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants