Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_app.js: render function or Component, and MDX access to props #86

Open
avaragado opened this issue Jul 26, 2018 · 2 comments
Open

_app.js: render function or Component, and MDX access to props #86

avaragado opened this issue Jul 26, 2018 · 2 comments

Comments

@avaragado
Copy link

avaragado commented Jul 26, 2018

In the README, the Custom App section talks about using the render function to pass props to child routes.

In the equivalent page in the nicely formatted doc there's no mention of using this render function. It mentions using Component instead.

Which approach should we be using?

And also, the reason I went down this hole: I can use _app.js to pass props to child routes. I can access these props in JS files: they're provided to the React component exported from the file.

How do I access these props in MDX files?

@avaragado
Copy link
Author

To expand on the second question. Consider this _app.js:

// _app.js

import React from 'react';

const App = props => {
    const { render } = props;

    return (
        <React.Fragment>
            {render({ foobar: 12345 })
        </React.Fragment>
    );
};

export default App;

And now this MDX file under the doc root:

import { Box } from 'rebass';

How do I access `foobar` here?

@jxnblk
Copy link
Member

jxnblk commented Jul 26, 2018

Either render or Component should work, but Component is probably a simpler, more React-like approach. As for props to MDX components, that isn’t supported yet – was a feature in early MDX that got removed along the way, but I think it’s coming back

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants