0

this is now

http://localhost:8001/components/button/

I want to

http://localhost:8001/components/button/?theme=dark

I used

browserHistory.push({
  pathname: '',
  query: {theme: dark},
})

and

browserHistory.push({
  pathname: 'components/button',
  query: {theme: dark},
})

and 

browserHistory.push({
  pathname: 'button',
  query: {theme: dark},
})

All failed.

How can i do? Can you help me, thank you!

2
  • can't you just do browserHistory.push("/components/button/?theme=dark") or try browserHistory.push({ pathname: 'components/button', search: '?theme: dark', }) Commented Sep 8, 2020 at 8:10
  • @dikuw result is localhost:8001/components/button/components/button/?theme=dark Commented Sep 8, 2020 at 8:23

2 Answers 2

1

You could just use a string literal and push onto history.

browserHistory.push(`components/button?theme=${dark}`)
Sign up to request clarification or add additional context in comments.

1 Comment

I used. it is same like ` pathname: 'components/button',` and result is localhost:8001/components/button/components/button/?theme=dark
0

You can use the push method as:

browserHistory.push({
  pathname: '/components/button',
  search: '?theme=dark'
})

or simple as:

browserHistory.push('/components/button?theme=dark')

2 Comments

It will be /components/button/components/button/?theme=dark
this is /components/button/ , not /components/button . So it does't work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.