react-csr
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

react-csr

Sample

You can use <NoSSR></NoSSR> to wrap the components wish to be rendered client side.

import { NoSSR } from './index';
import React from 'react';
 
class Com1 extends React.Component {
  render() {
    return <div></div>;
  }
}
 
const Com2: React.FC = () => {
  return <div></div>;
};
 
const Page = () => {
  return (
    <div>
      <NoSSR>
        <Com1 />>
        <Com2 />>
      </NoSSR>
    </div>
  );
};

Or you can warp your component with a function

import { noSSR } from './index';
import React from 'react';
 
class Com1 extends React.Component {
  render() {
    return <div></div>;
  }
}
 
const Com2: React.FC = () => {
  return <div></div>;
};
 
const WrappedCom1 = noSSR(Com1);
 
const WrappedCom2 = noSSR(Com2);
 
const WrappedCom3 = noSSR(() => <div></div>);
 
interface Props {
  a: string;
  b: boolean;
  c: number;
}
 
const WrappedCom4 = noSSR<Props>(({ a, b, c }) => {
  return (
    <div>
      {a},{b}{c}
    </div>
  );
});

Package Sidebar

Install

npm i react-csr

Weekly Downloads

2

Version

0.1.0

License

MIT

Unpacked Size

5.41 kB

Total Files

7

Last publish

Collaborators

  • ztytotoro