title: How to reload layout in Python Dash every time page is reloaded when app is passed as parameter?
body: <p>If you want to reload layout every page reload you do this:</p>
  <pre><code>app.layout = myfunction
  </code></pre>
  <p>NOTE: calling my function without parenthesis, like this would be wrong:</p>
  <pre><code>app.layout = myfunction()
  </code></pre>
  <p>But what if I want to call that function passing parameters?</p>
  <pre><code>app.layout = myfunction????
  </code></pre>
  <p>I’ve made a workaround by creating a dummy function like this</p>
  <pre><code>def serve_layout():
      return layout(app) # I pass app to use app.callbacks
  
  app.layout = serve_layout
  </code></pre>
  <h2>However</h2>
  <p>I am getting lots of errors about callbacks telling me that there are duplicate callbacks, which there really aren’t.</p>
  <p>ERROR:</p>
  <pre><code>In the callback for output(s):
    information-container.style
  Output 0 (information-container.style) is already in use.
  Any given output can only have one callback that sets it.
  To resolve this situation, try combining these into
  one callback function, distinguishing the trigger
  by using `dash.callback_context` if necessary.
  </code></pre>
  <p>I think this error is because I am passing the app as parameter (I need to do this to manage app.callbacks for every component because my app is pretty large) and somehow this type of paradigm is conflicting with Dash paradigm.</p>
  <p>Any help is appreciated</p>
  <p>source code:</p>
  <pre><code>
  import dash
  from layout import layout # layout is where i define all layout logic/ components
  
  def serve_layout():
      return layout(app)
  
  app = dash.Dash(__name__)
  
  app.layout = serve_layout
  app.title = 'Example app'
  if __name__ == &quot;__main__&quot;:
      app.run_server(debug=True,
                     host='0.0.0.0')
  </code></pre>