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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -