H
H
hateyyyy2016-09-22 17:34:46
React
hateyyyy, 2016-09-22 17:34:46

How does the match function work in server rendering?

Hello, I don’t quite understand why they are needed and how then I work with some parameters that are passed to this function.

match({ routes, location: req.url }, (error, redirectLocation, renderProps) => {});

Everything is clear with these parameters, but there are also others:
1) Options - it seems like it forms a history, which will then be applied (Although I don’t quite understand how)
2) history - why is it needed, if there are options, which forms the future history or what am I not understanding?
And here's another question, how to set a basename on the server, so that when you go to localhost, you immediately write something like this localhost / base. I tried to set it in options, but somehow it did not work out.
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Gushchin, 2016-09-23
@hateyyyy

According to documentation :
Accordingly, you have three options:

// автоматически создаст историю
match({ routes, location})

// автоматически создаст историю, при этом передав параметр someOption
// выглядеть это будет примерно так 
// createMemoryHistory(options)
match({ routes, location, someOption })

// вы создаете историю сами (звучит эпично)
match({ routes, location, history })

What basename is downloading - then you can just pass it as an option:
You will most likely need to manually redirect from / to /base.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question