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

refactor: remove unnecessary code #309

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

# production
/**/lib
/**/bundles
/**/build
/**/dist
/library/browser
/library/styles

# misc
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ The `@asyncapi/react-component` package has 3 crafted JS modules to be used in v
- `esm` (ECMAScript Modules) is intended for use in a single-page applications with predefined environments like [`create-react-app`](https://github.com/facebook/create-react-app) that are capable of resolving dependencies (via Webpack, Browserify, etc). It can also be used on the server side (for tasks like Server Side Rendering) when the application is using `esm`.
- `cjs` (CommonJS Modules) similar uses as for `esm` modules, but using CommonJS modules.
- `umd` (Universal Module Definition) is a dependency-free module that includes everything you need to serve AsyncAPI documentation (however [React](https://github.com/facebook/react/tree/master/packages/react) and [ReactDOM](https://github.com/facebook/react/tree/master/packages/react-dom) dependencies must be served separately) on a single-page application that can't resolve npm module dependencies or in normal HTML page. We have 2 types of minified `umd` bundles, with and without [AsyncAPI Parser](https://github.com/asyncapi/parser-js) in paths:
- `@asyncapi/react-component/bundles/umd/asyncapi-ui.min.js`
- `@asyncapi/react-component/bundles/umd/asyncapi-ui.without-parser.min.js`
- `@asyncapi/react-component/browser/index.js`
- `@asyncapi/react-component/browser/without-parser.js`

## Development

Expand Down
7 changes: 4 additions & 3 deletions docs/usage/nextjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ The `@asyncapi/react-component` package has a special `umd` bundle that can be u
import dynamic from 'next/dynamic';
import "@asyncapi/react-component/styles/default.min.css";

// Import component without SSR/SSG
const AsyncAPIComponent = dynamic(() => import('@asyncapi/react-component/browser'), { ssr: false });

export default function AsyncAPIPreview ({ schema, config }) {
// Render on the browser only
if (typeof navigator === 'undefined') return null;
// Import component only in the browser
const AsyncAPIUI = dynamic(() => import('@asyncapi/react-component/bundles/umd/asyncapi-ui.min'));

return schema && <AsyncAPIUI schema={code} config={config} />;
return schema && <AsyncAPIComponent schema={code} config={config} />;
}
```
Loading