relayjs - how to pass value to the root query in react-router-relay -
suppose have following root query in relay react-router-relay project:
export default { calc: () => relay.ql`query querytype ($number: string) { auth (number: $number) }`, }
initial value of $number
comes server hidden input , want use number in first query server. how can pass $number
query using current react-router-relay api? neither queryparam
or stateparam
.
you should able like:
import {createhistory} 'history'; import react 'react'; import reactdom 'react-dom'; import {route, router} 'react-router-relay'; import mycomponent './components/mycomponent'; import mycomponentqueries './routes/mycomponentqueries'; function addauthparam(params, route) { return { ...params, number: 'secret', }; } reactdom.render( <router history={createhistory()} createelement={reactrouterrelay.createelement}> <route component={mycomponent} path="/thing/:id" prepareparams={addauthparam} queries={mycomponentqueries} /> </router>, document.getelementbyid('relay-root') );
prepareparams
added in react-router-relay in v0.6.2. above syntax should work or v0.7.0 (the current release) well.
Comments
Post a Comment