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

branch 0204 set index doesn't seem to work #8

Closed
country-bumpkin-software opened this issue Jan 16, 2022 · 2 comments
Closed

branch 0204 set index doesn't seem to work #8

country-bumpkin-software opened this issue Jan 16, 2022 · 2 comments

Comments

@country-bumpkin-software

When I use branch 2040-set-index I get the following error:

ERROR in ./src/components/Bookables/BookablesList.js 13:27-43
export 'bookables'.'filter' (imported as 'bookables') was not found in '../../static.json' (possible exports: 0, 1, 2, 3, 4, 5)
@ ./src/components/Bookables/BookablesPage.js 4:0-44 9:35-48
@ ./src/components/App.js 7:0-54 124:40-53
@ ./src/index.js 5:0-38 7:38-41

ERROR in ./src/components/Bookables/BookablesList.js 15:14-23
Should not import the named export 'bookables' (imported as 'bookables') from default-exporting module (only default export is available soon)
@ ./src/components/Bookables/BookablesPage.js 4:0-44 9:35-48
@ ./src/components/App.js 7:0-54 124:40-53
@ ./src/index.js 5:0-38 7:38-41

webpack 5.66.0 compiled with 2 errors in 102 ms

@country-bumpkin-software country-bumpkin-software changed the title back 2040 set index doesn't seem to work branch 2040 set index doesn't seem to work Jan 16, 2022
@country-bumpkin-software country-bumpkin-software changed the title branch 2040 set index doesn't seem to work branch 0204 set index doesn't seem to work Jan 16, 2022
@country-bumpkin-software
Copy link
Author

I had to change the code as follows:

import {useState} from 'react';
const data = require('../../static.json')

export default function BookablesList () {
    console.log(data);
  const group = "Rooms";

  const bookablesInGroup = data.bookables.filter(b => b.group === group);
  const [bookableIndex, setBookableIndex] = useState(1);
    console.log(data);
  return (
    <ul className="bookables items-list-nav">
      {bookablesInGroup.map((b, i) => (
        <li
          key={b.id}
          className={i === bookableIndex ? "selected" : null}
        >
          <button
            className="btn"
            onClick={() => setBookableIndex(i)}
          >
            {b.title}
          </button>
        </li>
      ))}
    </ul>
  );
}

@mortenbrudvik
Copy link

This worked for me

import data from "../../static.json";

export default function BookablesList () {

  const group = "Rooms";

  const bookablesInGroup = data.bookables.filter(b => b.group === group);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants