Posts

Showing posts with the label react-context

React props are being evaluated even if the component is still suppose to be rendered

React props are being evaluated even if the component is still suppose to be rendered I have a wrapper for my components that tells them not to render until they are done loading that looks like this import React from 'react'; import LoadingSpinner from 'vivid.react.components/atoms/LoadingSpinner'; class Wrapper extends React.Component { componentDidMount() { this.props.getInitialState(); } render() { const { error, isLoadingInitialState } = this.props; return ( {!!error && Error: {error.message} } {isLoadingInitialState ? <LoadingSpinner/> : children } </div> ) } }; export default Wrapper; However, when I used this wrapper inside a Context Consumer, the props of the children are still being evaluated even if the LoadingInitialState is true and the children is not supposed to render. const S...