-
Notifications
You must be signed in to change notification settings - Fork 6
Description
The issue is simple, the Consumer props doesn't exists until the render method is called, that's because with-context wrap your component with a parent that renders the consumer itself and then it inject the props in your component.
I have a case that I need to have the props before the render is called and I tried everything that I can think to workaround this and didn't managed to get working. So if someone could give any ideas how to fix it or submit a pull request, I will be very thankful.
Just to make easier for others, what I tried so far:
- I tried to get consumer value through the var
Context.Consumerbut doesn't seens to exist the value inside it. But if I could get the value from that, I could easily do something like this:
function Connected(props) {
PureComponent.call(this, Object.assign(Context.Consumer.value, props));
}
-
Tried to wrap the Connected component inside another component that this second one would pass the props on the render method then the Wrapped Component always would have the props, but I couldn't make it work.
-
Tried to somehow call render in Connected constructor, but I don't think this is possible.