D
D
dron1122021-04-11 19:45:19
React
dron112, 2021-04-11 19:45:19

Why does push in React change Url?

<p onClick={() => this.props.history.push('/')}>клик</p>


Why does this command change the url ? Why does the push method work for history, because history is not an array, but an object?


What field of the history object is my slash pushed to?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alice, 2021-04-11
@w3bsmes

Why does this command change the url?
If you do not use react-router , then look here
What field of the history object is my slash pushed to?
state

Y
y0u, 2021-04-11
@y0u

const obj = {
   push: (param) => console.log('push ', param),
}

obj.push();

Why does the push method work for obj, because obj is not an array, but an object?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question