score:3
try the following:
render() {
const showLocalLoader = this.props.LoaderStore.showLocalLoader
return(
<div>
{/* note router container and "with router" wrapper one level up. */}
<Switch>
<Route render={()=>{return <MyComponent isLoading={showLocalLoader}><CoolChildComponent/></MyComponent>}} />
</Switch>
</div>
);
}
this will cause the correct value to be sent as prop to the Route, there is an issue that sometimes the change in value doesn't trigger re-rendering when the observable is nested inside the return value of render.
let me know if it worked
score:0
sounds like you are missing an observer wrapper for MyComponent you can use @observer if you have support for decorators else you should enable decorators as shown here,
hopes that helps, if that's the issue here is a little explanation:
when you set an observable in a mobx store you can react to a change of this observable in a few ways (i'm just listing 2 for more options see the mobx docs):
both this methods work on the same principles, just that in the option of observable what happens is that the render function works like autorun works
it's pretty straight forward if you have an observable inside the function it will trigger it every time the observable in the function scope changes
good luck!
Source: stackoverflow.com
Related Query
- MobX, React Router v4, Route using render function not observing and re-rendering when store changes
- You should not use Route or withRouter() outside a Router when using react-router 4 and styled-component in react
- React Router V5 not rendering route when clicking Link, but back and forward buttons work?
- Uncaught TypeError rendering <Router> using React Router in ES6: type.toUpperCase is not a function
- React Router Render props is not rendering component when using params
- Route not found on refresh using react router and express on heroku
- React view is not rendering when using react router 4 and redux
- How to fix nextCreate is not a function setting up useMemo setting up authentication react router and hooks
- How to pass the match when using render in Route component from react router (v4)
- Using render in react router dom with a private route
- React router 4 `Link` component only changing the url and not updating the route
- Route not defined react router and spring boot server
- How to intercept back button in a React SPA using function components and React Router v5
- React Router v6 child route not rendering
- React router v4.2.2: using a string instead of function inside component prop of Route results in error
- React Router V4 - Route between components and not entire page
- React Router v6 and recursive rendering of Route component from data
- Use serverless function to findById in MongoDB Database via Mongoose, and render result in React form - not working
- react router not rendering components at route
- CSS not changing when using React Router to route to another component
- React Router will not render Route component unless page is refreshed
- React router does not render route when URL accessed directly
- Nested routes and not found route in react router dom v5
- How to render a <Route/> from react-route-dom using a object and not a component / function
- Not able to set the JSON object of Arrays in React js using axios.get function and display the object of Arrays in table
- React Router - route using MemoryRouter and Router together (Some links use memory while others change the url)
- react router not rendering the component when using redux
- Getting this error while using React router TypeError: type.toUpperCase is not a function
- React router private route not rendering
- React Component not rendering on using react router 4
More Query from same tag
- Value of react context is not updated
- Anchor Link Libraries not working at all in my React project
- React Redux Thunk with callback to another function -- TypeError: Cannot read property 'then' of undefined
- How to call API and stores results in a state when a form submit is clicked using react hooks
- reactjs + typescript getting error: Type 'string' is not assignable to type 'never'
- Cannot find module 'react' from 'Provider.js'
- Load a React component at runtime from a plain JSX external script
- How to set breakpoints when overriding theme variables in createMuiTheme
- How to set default selected items in Autocomplete
- React form with Formik error : Each child in a list should have a unique "key" prop
- error in react " Attempted import error: 'TodoItem' is not exported from './Todoitem'. "
- State is being deleted in React JS
- Footer at bottom of page for responsive screen
- Deploy on Github Pages
- React not re-rendering on state change?
- POST with Body Not Passing Cookies
- How to upgrade from react-router to react-router-dom?
- React Material UI ExpansionPanel Remove Borders
- How to select all and unselect by specific row in table by checkbox - React Js
- Iterating through HTMLcollection in React,js
- npm install -g create-react-app Giving error -4048 , -4051 on Windows
- How to access the store in React components?
- How to create Auxiliary (Higher Order Component) in preact?
- React need this in the useEffect but not as a dependency
- how to cancel web requests using interceptors?
- ReactJS fetch not returning error and returning incorrect data
- ReactJS - Add slug to url (dynamic slug in frontend)
- Youtube video embed responsive size in flexbox row
- event.target.value question with React.js
- Axios is undefined in React, error: Uncaught TypeError: Cannot read property 'post' of undefined