4.7.0
Here are some helper components and functions for starting react projects
Provides support for internationalization
Function
:
Returns i18n ready for use (check
https://www.npmjs.com/package/i18n
)
import { i18n } from '@tecsinapse/react-boilerplate/build/i18n/i18n';
import { Button } from '@tecsinapse/ui-kit';
export const ConfirmButton = <Button label={i18n._(t`Confirmar`)} />;
Composes support for multiple i18n languages
(Element)
Receives a react component
Function
:
Returns a context
This method initializes your react app, useful to replace defaults on index
(object)
Object containing all parameters to initialize the application for web
Name | Description |
---|---|
props.hotjarId string
|
Hotjar code for your app |
props.analyticsCode string
|
Google analytics code for tracking (default = null) |
props.reduxOptions object
|
Initial redux options (default = {}) |
props.reduxOptions.appState object
|
Initial app state (default = null) |
props.axiosOptions object
|
Initial axios config (default = {}) |
props.apolloOptions object
|
Initial apollo config (default = {}) |
props.apolloOptions.offlineApolloCacheOptions object
|
Initial apollo cache config (default = null) |
props.keycloakOptions object
|
Initial KC config (default = {}) |
props.keycloakOptions.publicUrls object
|
Initial public URL's (default = []) |
props.sentryOptions object
|
Initial sentry tracker config |
props.idpHint string
|
idpHint for kc login |
props.renderFunction Function
|
Render function |
init({
analyticsCode: "AAAA",
hotjarId: "BBBB",
sentryOptions: {
dsn: 'https://sentry.io/',
release: process.env.REACT_APP_VERSION,
environment: process.env.REACT_APP_HOST,
},
reduxOptions: {
appState: store,
middlewares: [middlewares],
}
axiosOptions: {
axiosBaseUri: `http://localhost`,
interceptors:{
request: [ [successInterceptor1, errorInterceptor1], [successInterceptor2, errorInterceptor2] ],
response: [ [successInterceptor3, errorInterceptor3], [successInterceptor4, errorInterceptor4] ],
}
},
apolloOptions: {
offlineApolloCacheOptions: null,
uri: `http://localhost/api`,
connectToDevTools: true,
},
keycloakOptions: {
keycloakConfig: {},
logoutFunction: () => {},
publicUrls: ['/login'],
},
renderFunction: props => {
ReactDOM.render(
<Providers />,
document.getElementById('root')
);
}
});
Composes keycloack auth manager
(Element)
Receives a react component
Function
:
Returns a context
This element provides all resources to children components
(object)
Object containing all parameters to JSX component
Name | Description |
---|---|
props.keycloak object
|
Keycloack config |
props.client object
|
Apollo client config |
props.store object
|
Redux store provider |
props.children object
|
Children element to render |
props.catalogs object
(default {} )
|
Object containing list of i18n languages available |
props.themeVariant string
(default 'orange' )
|
UI-KIT theme variant |
props.language (string | null)
(default null )
|
Language being loaded on runtime |
props.themeOverrides object
(default {} )
|
Object containing material-ui theme overrides |
JSX.Element
:
React element
<Providers themeVariant="orange" catalogs={{ 'pt-br': () => import(`./locales/pt-br/messages`), en: () => import(`./locales/en/messages`) }} themeOverrides={{ MuiBadge: { badge: { backgroundColor: #FFF, } } }} {...props} > <App /> </Providers>
This method render a loading circle at screen
This method hides the loading circle at screen
Composes wrapper to use snackbar alerts
(Element)
Receives a react component
Function
:
Returns a context