Open ghmendonca opened 6 years ago
Hi @ghmendonca , I tried to understand your situation, but I still cannot get your point. Would you please show me a live demo or give more description to help me to understand that?
@SunHuawei, this is easy: He (and me) needs the context
before rendering anything.
@SunHuawei, this is easy: He (and me) needs the
context
before rendering anything.
i guess this is not possible, coz react context passed to Consumer which available only then doms engine are running , so only in render
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:
Context.Consumer
but 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: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.