ericclemmons / react-resolver

Async rendering & data-fetching for universal React applications.
https://ericclemmons.github.io/react-resolver
Other
1.65k stars 52 forks source link

Some way of manipulating data before passing it to component #129

Closed jbreemhaar closed 6 years ago

jbreemhaar commented 7 years ago

I think https://github.com/ericclemmons/react-resolver/issues/84 is related, but just to be sure; is there any way of transforming data before passing it on to the component?

If I currently want to do some stuff with the data I'd need to put it on state, and then use that in the render. For example wanting to have some class created for JSON data.

pwmckenna commented 7 years ago

give recompose a try. say you want to just rename options to componentOptions, this would work.

import { compose, mapProps } from 'recompose';

export default compose(
    resolve("options", (props) => {}),
    mapProps(({ options }) => ({
        componentOptions: options
    })
})(MyOptionsComponent);
pwmckenna commented 6 years ago

Going to close this for now. Let me know if there's a use case that would still require a react-resolver change. Thanks!