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

$onUpdated Hook not functioning on imported component #4272

Open
ghost opened this issue May 18, 2024 · 0 comments
Open

$onUpdated Hook not functioning on imported component #4272

ghost opened this issue May 18, 2024 · 0 comments

Comments

@ghost
Copy link

ghost commented May 18, 2024

I've encountered a problem with lifecycle hooks. Specifically, when I import a component, the $onUpdated hook doesn't seem to function properly when the props are updated in the main component.

Expected Behaviour
Retrieve the updated data on the $onUpdated hook of the Subcomponent when data is updated in the main component.

Actual Behaviour
No data is received

Please check:

app.js

...
import chart from "../components/chart.f7"
Framework7.registerComponent(
  'x-chart', chart
)
...

Main Chart Component

<template>
  <div class="page" data-name="charts">
    <div class="navbar">
      <div class="navbar-bg"></div>
      <div class="navbar-inner">
        <div class="left">
          <a href="#" class="link back">
            <i class="icon icon-back"></i>
          </a>
        </div>
        <div class="title">About</div>
      </div>
    </div>
    <div class="page-content">
      <div class="block-title">Charts</div>
      <div class="block">
        <x-chart data-title="Monthly Sales" data-chartdata="${chartdata}"></x-chart>
      </div>
    </div>
  </div>
</template>
<script>
  export default (props, { $on, $update }) => {
    let chartdata = [1, 2, 3]
    $on('pageInit', function () {
      setTimeout(function () {
        chartdata = [3, 4, 5]
        $update()
      }, 2000)
    })
    return $render;
  };
</script>

Subcomponent: components/chart.f7"

<template>
    <div>
        <div>${props.dataTitle}</div>
        <canvas></canvas>
    </div>
</template>
<script>
    export default (props, { $on, $onUpdated }) => {
        console.log(props)
        $onUpdated(function () {
            console.log(props)
        })
        return $render;
    };
</script>
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

0 participants