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

DOM is not getting updated #73

Open
andruschka opened this issue Dec 6, 2017 · 3 comments
Open

DOM is not getting updated #73

andruschka opened this issue Dec 6, 2017 · 3 comments

Comments

@andruschka
Copy link

I have a yo-yo function that takes an object param with an array -> checkpoints and and a bool -> showAllCheckpoints. When showAllCheckpoints is false or undefined I slice the checkpoints array to 3 items. If the showAllCheckpoints flag is set to true, I dont do that. The checkpoints then get mapped to further yo-yo functions that generates Elems.
The problem now: when I update yo-yo with "showAllCheckpoints: true" the DOM does not get updated. I log the checkpoints.length before returning the yo-yo temp. string and it is logged right:
first with length = 3 and then after updating with length = 7.
Am I doing something wrong???

@andruschka
Copy link
Author

andruschka commented Dec 6, 2017


const TrackingBody = ({ checkpoints,  showAllCheckpoints }) => {
  let tCheckpoints = prepareCheckpoints(checkpoints)
  let moreButton = null

  if (tCheckpoints.length > 3 && !showAllCheckpoints) {
    moreButton = MoreButton(T.translate('more', query.lang.code))
    tCheckpoints = tCheckpoints.slice(0, 3)
  }    

  console.log(tCheckpoints.length)

  return html`
    <div class="parcel_lab_tracking" id="pl-t-${tHeader.id}">
      <div class="pl-box-body">

          <div class="pl-padded">
            ${ tCheckpoints.map(tCp => Checkpoint(tCp)) }
            ${ moreButton }
          </div>

        </div>
...

@andruschka
Copy link
Author

The showAllCheckpoints is getting updated correctly, -> the TrackingBody() funciton is rerun but the dom does not change ...

@andruschka
Copy link
Author

andruschka commented Dec 6, 2017

Ok I think I fixed it but I am not sure if it is a bug or maybe I am just stupid...
The TrackingBody element is wrapped by an App element, which is the root of the app.
There I had following line:

const App = state => {
  if (!state.query || !state.checkpoints) return html`<span>Loading</span>`  // <~ this caused the bug

  const trackingBody = TrackingBody(state)

  return html`<div>${ trackingBody } ... some more components ... </div>`

After removing the line, everything works fine again...

@andruschka andruschka changed the title DOM is not getting updated on update. DOM is not getting updated Dec 6, 2017
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

1 participant