# Dynamic layouts break auto-generated callbacks

**URL:** <https://community.plotly.com/t/dynamic-layouts-break-auto-generated-callbacks/53956>\
**Category:** Dash Python\
**Created:** [June 17, 2021, 4:40am UTC](https://community.plotly.com/t/dynamic-layouts-break-auto-generated-callbacks/53956 "2021-06-17T04:40:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![klappec](https://avatars.discourse-cdn.com/v4/letter/k/77aa72/32.png) [@klappec](https://community.plotly.com/u/klappec)\
**Post date:** [June 17, 2021, 4:40am UTC](https://community.plotly.com/t/dynamic-layouts-break-auto-generated-callbacks/53956/1 "2021-06-17T04:40:31Z")

</div>

Dash==1.20.0

I have a function which: accepts (dash\_app, component\_id) as arguments, generates a Dash component and sets a callback on it, then returns the component.

If used with a static layout, this works fine.

If used with a dynamic layout (app.layout = some\_layout\_func), it breaks, complaining I have duplicate callback outputs and inputs.

(I have tried functools.lru\_cache in various places but this does not help, I suspect its somehow related to threading? The function seems to get called multiple times w/ the same cache key… despite the fact its supposed to be a cached function. )

how to fix this to work with dynamic layouts? thanks
