question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Approach question - Passing events to header

See original GitHub issue

Hi,

I’ve downloaded the kit and altered my app.js to include a site header, I want to have a mini basket in the header and want to pass an “AddToCart” event from a child page into the header.

App.js now looks like this

` render() {

return !this.props.error ? (

  <div>

    <Header data={this.state.navData} isShopPage={this.state.isShopPage} />

    {this.props.children}

    <Footer />

  </div>

) : this.props.children;

}`

I’ve been using the kit to get to grips with react so this may be a newbie question but can someone explain the best way to wire up and pass an event from a child route back up into the app and over to the header component?

Thanks

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ucaycommented, Oct 7, 2016

Same with me, and I’ve tried something like this

<Header 
    data={this.state.navData} 
    isShopPage={this.state.isShopPage} 
    shopData={this.props.children.props.shopData}
/>

so, i just need to add props in children’s index.js (in routes directory)

return {
      title,
      component: <Shop title={title} shopData={someVar}/>
    };

still looking the best way to do this.

0reactions
ulanicommented, May 27, 2021

@pcooper1979 thank you very much for crating this issue! Unfortunately, we have close it due to inactivity. Feel free to re-open it or join our Discord channel for discussion.

NOTE: The main branch has been updated with React Starter Kit v2, using JAM-style architecture.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTP Authorization Header in EventSource (Server Sent ...
I need to set an Authorization header to an HTML5 EventSource. As Server Sent Events seems to be disused since Websockets appeared, I...
Read more >
HTTP/1.1: Header Field Definitions
If an Accept-Language header is present, then all languages which are assigned a quality factor greater than 0 are acceptable. It might be...
Read more >
Lambda@Edge event structure - Amazon CloudFront
The following topics describe the request and response event objects that CloudFront passes to a Lambda@Edge function when it's triggered.
Read more >
XMLHttpRequest.setRequestHeader() - Web APIs | MDN
The XMLHttpRequest method setRequestHeader() sets the value of an HTTP request header. When using setRequestHeader() , you must call it ...
Read more >
Twilio Function Execution
If your Function Code does not contain a handler method, Twilio Functions will ... The event object contains the request parameters and headers...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found