mohux / react-brackets

Reusable and customizable react brackets component, you can use it to build components such as single elimination, or double elimination brackets
105 stars 47 forks source link

Help with mobile #25

Open MWTuttle opened 1 year ago

MWTuttle commented 1 year ago

Hello and thank you for making such a nice looking library.

I am trying to get this working with React Native. I was hoping someone could give me some hints on how to get started. I tried getting the minimal first example working but it is breaking my build, and I don't have experience getting web libraries working on mobile.

Oliver-Looney commented 1 year ago

What error are you getting? I have just opened a pr to update the examples, https://github.com/mohux/react-brackets/pull/26

The working first example would now be:

import { Bracket, IRoundProps } from 'react-brackets';

const rounds: IRoundProps[] = [
  {
    title: 'Round one',
    seeds: [
      {
        id: 1,
        date: new Date().toDateString(),
        teams: [{ name: 'Team A' }, { name: 'Team B' }],
      },
      {
        id: 2,
        date: new Date().toDateString(),
        teams: [{ name: 'Team C' }, { name: 'Team D' }],
      },
    ],
  },
  {
    title: 'Round one',
    seeds: [
      {
        id: 3,
        date: new Date().toDateString(),
        teams: [{ name: 'Team A' }, { name: 'Team C' }],
      },
    ],
  },
];
const Component = () => {
  return <Bracket rounds={rounds} />;
};
MWTuttle commented 1 year ago

Here's what I have in NewBracket.tsx:

import { View, Text } from 'react-native';
import { Bracket, IRoundProps } from 'react-brackets';

const rounds: IRoundProps[] = [
  {
    title: 'Round one',
    seeds: [
      {
        id: 1,
        date: new Date().toDateString(),
        teams: [{ name: 'Team A' }, { name: 'Team B' }],
      },
      {
        id: 2,
        date: new Date().toDateString(),
        teams: [{ name: 'Team C' }, { name: 'Team D' }],
      },
    ],
  },
  {
    title: 'Round one',
    seeds: [
      {
        id: 3,
        date: new Date().toDateString(),
        teams: [{ name: 'Team A' }, { name: 'Team C' }],
      },
    ],
  },
];

const NewBracket = () => {
    return <Bracket rounds={rounds} />;
};
export default NewBracket;

and I get the following:

Screen Shot 2023-06-27 at 10 32 42
Oliver-Looney commented 1 year ago

It looks like NewBracket returns undefined

Does it work if you do:

const NewBracket = () => {
  return <Bracket rounds={rounds} />;
};
MWTuttle commented 1 year ago

Sorry @Oliver-Looney , I'm not sure if I follow your suggestion. That const statement looks identical to what I have, unless you are suggesting I remove the export?

Oliver-Looney commented 1 year ago

I replied before you edited your code example, Screenshot_20230627_202821

MWTuttle commented 1 year ago

Ha, sorry for the mixup.

Screen Shot 2023-06-27 at 21 39 56
MWTuttle commented 1 year ago

Hi @Oliver-Looney, I was wondering if you had any more insights you could share.