Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

Calendar missing headers on initial render with Preact #8

@jwrlee88

Description

@jwrlee88

Hello,

I tried using this component with my Preact project and I noticed something odd. When the component using react-available times first renders, it renders like this image (hosted on imgur) http://i.imgur.com/u90KQhM.png

and then, when I resize the window, (e.g., I right click and open the developer console in chrome) it looks like this: http://i.imgur.com/a7Jid5U.png

I don't think it's Preact that's the issue, since Preact is just a lightweight version of React. What I've noticed is that the AvailableWidth prop gets passed down and that's what gets used to set the initial width of the headers. However, I think the problem is that the available width prop gets set to 0 upon initial load.

What is a good way I can fix this / workaround this? I would like the calendar to load fully upon initial render, and not have to have the window resized to make the headers show up.

Thank you in advance!

Here is my code to reproduce:

  1. Calendar.js
 import AvailableTimes from 'react-available-times';

class Calendar extends Component {
    render(){
        return(
                <div className="calendar">

                <AvailableTimes
                    className="calendar"
                    weekStartsOn="monday"
                    onChange={(selections) => {
                        selections.forEach(({ start, end }) => {
                            console.log('Start:', start, 'End:', end);
                        })
                    }}
                    onEventsRequested={({ calendarId, start, end, callback }) => {
                        loadMoreEvents(calendarId, start, end).then(callback);
                    }}
                    initialSelections={[
                        { start: new Date(2018, 7, 15, 8, 0), end: new Date(2018, 7, 16, 8, 0) }
                    ]}
                    height={800}
                    recurring={false}
                    availableDays={['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']}
                    availableHourRange={{ start: 7, end: 20 }}
                />
                </div>
        )
    }
}

export default Calendar;
  1. Routes.js

export default class Routes extends Component {
  render () {
    return (
      <ConnectedRouter {...this.props}>
        <div>
          <Navbar/>
          <NotificationsContainer/>
          <Switch>
            {/* Public Routes */}
            <Route path='/calendar' component={Calendar}/>
          </Switch>
        </div>
      </ConnectedRouter>
    )
  }
}```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions