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

CustomApp not work #2485

Closed
data-server opened this issue Oct 30, 2018 · 6 comments
Closed

CustomApp not work #2485

data-server opened this issue Oct 30, 2018 · 6 comments
Assignees
Labels

Comments

@data-server
Copy link

Please do not submit support requests or "How to" questions here. For that, go to StackOverflow.

What you were expecting:

What happened instead:

Steps to reproduce:

Related code:

Edit nn3mrv8zyj

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Provider } from 'react-redux';
import createHistory from 'history/createHashHistory';
import { ConnectedRouter } from 'react-router-redux';
import { Switch, Route } from 'react-router-dom';
import withContext from 'recompose/withContext';
import { TranslationProvider, Resource } from 'react-admin';
import restProvider from 'ra-data-simple-rest';
import defaultMessages from 'ra-language-english';
import { MuiThemeProvider,createMuiTheme  } from '@material-ui/core/styles';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import Typography from '@material-ui/core/Typography';

import createAdminStore from './createAdminStore';
// import messages from './i18n';

// your app components
// import Dashboard from './Dashboard';
import { UserList } from './User';

// side effects
const authProvider = () => Promise.resolve();
const dataProvider = restProvider('https://jsonplaceholder.typicode.com');
const i18nProvider = locale => {
    // if (locale !== 'en') {
    //     return messages[locale];
    // }
    return defaultMessages;
};
const history = createHistory();
const theme = createMuiTheme();
const App = () => (
    <Provider
        store={createAdminStore({
            authProvider,
            dataProvider,
            i18nProvider,
            history,
        })}
    >
        <TranslationProvider>
            <ConnectedRouter history={history}>
                <Resource name="users" context="registration" />
                <MuiThemeProvider theme={theme}>
                    <AppBar position="static" color="default">
                        <Toolbar>
                            <Typography variant="title" color="inherit">
                                My admin
                            </Typography>
                        </Toolbar>
                    </AppBar>
                    <Switch>
                        <Route exact path="/users" hasCreate render={(routeProps) => <UserList resource="users" {...routeProps} />} />
                    </Switch>
                </MuiThemeProvider>
            </ConnectedRouter>
        </TranslationProvider>
    </Provider>
);

export default withContext(
       {
           authProvider: PropTypes.func,
       },
   () => ({ authProvider }))

Other information:

Environment

  • React-admin version:
  • Last version that did not exhibit the issue (if applicable):
  • React version:
  • Browser:
  • Stack trace (in case of a JS error):
@fzaninotto
Copy link
Member

What do you mean "not works"? Please fill in the bug template and explain what you want and what you got instead.

@data-server
Copy link
Author

just want show list and filter, no sidebar, no auth control。

@fzaninotto
Copy link
Member

Confirmed and reproduced, the doc is wrong.

@data-server
Copy link
Author

https://codesandbox.io/s/nn3mrv8zyj , somthing wrong with the list page @fzaninotto

@mi-mazouz
Copy link

any updates?

mikaoelitiana pushed a commit to mikaoelitiana/react-admin that referenced this issue Nov 22, 2018
mikaoelitiana pushed a commit to mikaoelitiana/react-admin that referenced this issue Nov 22, 2018
@fzaninotto
Copy link
Member

@data-server I see warnings for missing hasEdit and other props, and I'll fix that in another PR. As for the warning for staticContext, can you please open a new issue?

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

No branches or pull requests

3 participants