question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Month and day does not work preview

See original GitHub issue

Do you want to request a feature or report a bug?

Bug

What’s the current behavior?

erro bigcalenddar

Code:

...
import BigCalendar from 'react-big-calendar';
import moment from 'moment';
import { getEvents } from '~/services/google-calendar';

import styles from './styles';

moment.locale('pt-BR');
BigCalendar.setLocalizer(BigCalendar.momentLocalizer(moment));

require('react-big-calendar/lib/css/react-big-calendar.css');

class Contatos extends Component {
  state = {
    events: [],
  };

  componentDidMount() {
    getEvents((events) => {
      this.setState({ events });
    });
  }

  render() {
    const { location } = this.props;

    return (
      <Layout loading={false} title="Agenda" location={location}>
        <BigCalendar events={this.state.events} />
      </Layout>
    );
  }
}

...

What’s the expected behavior?

Should work normally

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
igoramos77commented, Apr 7, 2021

Hello guys, i’m from Brazil, and i want change all react-big-calendar to portuguese-br (pt-BR/ptBR). With lib moment thats works, but, i need use date-fns, and thats not working, someone can help me, please ?

import { Calendar, momentLocalizer } from 'react-big-calendar';
import moment from 'moment';
import 'moment/locale/pt-br';
const localizer = momentLocalizer(moment);

const messages = {
        allDay: 'Dia Inteiro',
        previous: '<',
        next: '>',
        today: 'Hoje',
        month: 'Mês',
        week: 'Semana',
        day: 'Dia',
        agenda: 'Agenda',
        date: 'Data',
        time: 'Hora',
        event: 'Evento',
        showMore: (total) => `+ (${total}) Eventos`,

<Calendar
    style={{ height: '95%' }}
    eventPropGetter={(event) => {
        return {
            style: {
                backgroundColor: '#3f51b5',
                borderRadius: '8px',
                minHeight: '10px',
            },
        };
    }}
    messages={messages}
    selectable
    localizer={localizer}
    events={events}
    startAccessor="start"
    endAccessor="end"
    onSelectSlot={(slot) => handleOpenDialog(slot)}
    onSelectEvent={(event) => handleOpenEvent(event)}
/>

Captura de tela 2021-03-09 100115

Using date-fns:

  import { Calendar, dateFnsLocalizer } from 'react-big-calendar';
  
  import {  parse, startOfWeek, getDay } from 'date-fns';
  
  import 'date-fns/locale/pt-BR';
  
  const locales = {
      'pt-BR': require('date-fns/locale/pt-BR'),
  };
  
  const localizer = dateFnsLocalizer({
      format,
      parse,
      startOfWeek,
      getDay,
      locales,
  });

Captura de tela 2021-03-09 100506-2

Conseguiu resolver, @GusMartins499? Obrigado!

1reaction
jquensecommented, Aug 1, 2018

I’m gonna guess your events start and end dates are not Date objects?

Read more comments on GitHub >

github_iconTop Results From Across the Web

My video quick preview isn't working when… - Apple Community
Click on Apple icon on top left Menu bar, Force Quit: Preview and Quick Time Player (if they are running), and Relaunch: Finder....
Read more >
Mac QuickLook Preview Not Working (How to Fix) - YouTube
Here is exactly what to do when your mac finder spacebar preview is not working. All the important information is shown in the...
Read more >
For MONTHS my Preview has been been broken. Apple could ...
Try open Preview while pressing shift key. Then it wont't load last opened document (personally i found this feature annoying and have disabled ......
Read more >
How to Fix Excel Dates That Won't Change Format - Contextures
In the drop down list, click on the date format that your dates are currently displayed in. In this example, the dates are...
Read more >
FAQs - Preview App
Frequently Asked Questions to Preview. ... What does "2 months FREE" mean? ... Reels covers are not the same in Preview and Instagram...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found