JavaScript How to move between components in React move components between layers sketchup,eagle move components between sheets,

import React, { Component } from 'react'
import Head from './Head'
import Popular from './Popular'
import Movie from './Movie'
import Search from './Search'

class Flix extends Component {

constructor() {
    super()

    this.state = {
        id : 0,
    }
}

fetchDetails = (id) => {
this.setState({id : id})
}

render() {

    var dialogue //this is an array which I pass to Head

    if (this.state.id === 0) {
        return (

            <div>
                <Head subHeading={dialogue} />
                <Search />
                <Popular fetchDetails={this.fetchDetails}/>
            </div>

        );
    } else {
        return (

            <div>
                <Head subHeading={dialogue} />
                <Search/>
                <Movie id={this.state.id} />
            </div>

        );
    }
}
}

export default Flix;

So, what is happening is, Popular displays a list of popular movies and when user clicks on a movie it reutns the 'id' of that movie and that is passed to Movies to display more information about the clicked movie.

This whole system works and onclick I get more details about that movie but the way I have implemented this is that at start id=0 so, display popular movies and onclick id changes to some number than according to that display Movie details.

I used simple if statement for this.

My problem is as there is no back button how can implement a way such that after user gets the details he wants to come back to popular movies to the point where he scrolled down the list of popular movies. Basically like a back button.

At this point back button on browser doesn't work.

Answer:1

Get the offset of the window when showing the details and save it to the tate with something like:

this.setState ({
   scrollOffset: window.scrollTop
})

Then a button (or a Link or whatever component you want) and onClick bind a simple function that does this:

handleButton = () => {
    this.setState({
        id: 0 
    });
    window.scrollTo(0, this.state.scrollOffset);
}
Answer:2

how do I connect the button (which is in HTML page) to connect to php url, once the ON/OFF button is clicked. the code basically have to call the php once the button is clicked and when the php is ...

how do I connect the button (which is in HTML page) to connect to php url, once the ON/OFF button is clicked. the code basically have to call the php once the button is clicked and when the php is ...

  1. link html button to javascript function
  2. link html button to python function
  3. link html button to another page
  4. link html button to javascript
  5. link html button to php page
  6. link html button to php function
  7. link html button
  8. link html button to page
  9. link html button send
  10. html link button code
  11. html link button style
  12. link button html w3schools
  13. link button html css
  14. link button html bootstrap
  15. html link button generator
  16. html link button with image and text
  17. html link button to form
  18. html link button to new page
  19. html link button new tab
  20. html link button tag

When dynamically changing content within a div is there a way of delaying the display of the new content until all layout is complete? I am using javascript and ajax to update the contents of a div ...

When dynamically changing content within a div is there a way of delaying the display of the new content until all layout is complete? I am using javascript and ajax to update the contents of a div ...

I am trying to filter out all objects based on a string attribute like this: var data = $.parseJSON(valid_json); data = data.filter(function (el) { return (el.name == 'myName'); }); This returns ...

I am trying to filter out all objects based on a string attribute like this: var data = $.parseJSON(valid_json); data = data.filter(function (el) { return (el.name == 'myName'); }); This returns ...

  1. filter json string c#
  2. filter json string
  3. filter json string java
  4. filter json string javascript
  5. filter json string python
  6. filter json string jquery
  7. json filter string contains
  8. php filter json string
  9. filter json query string

I'm trying to divide 100 by a number, so I get the percentage of that number to put in a variable that is into a FOR ... and that FOR put the percentage inside an Array ... More or less This: var ...

I'm trying to divide 100 by a number, so I get the percentage of that number to put in a variable that is into a FOR ... and that FOR put the percentage inside an Array ... More or less This: var ...

  1. divide whole number javascript
  2. divide number using javascript
  3. divide number with string javascript
  4. javascript divide number into equal parts
  5. javascript divide number into array
  6. javascript divide number by 2
  7. javascript divide number integer
  8. javascript divide number into parts
  9. divide two numbers in javascript
  10. javascript divide number in array
  11. javascript divide number decimals