Skip to content

Instantly share code, notes, and snippets.

import styled from 'styled-components';
import { Typography } from 'antd';
export const StyledParagraph = styled(Typography.Paragraph)`
&& {
display: flex;
margin-bottom: 0;
font-size: 1.25rem;
}
`;
import { Form, Input } from 'antd';
...
const validatePhoneNumber = (rule, value, callback) => {
const phoneNumberPattern = /\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})/;
const isValid = phoneNumberPattern.test(value);
if (!isValid) {
return callback('Not a valid phone number');
}
return callback();
class JitsiView extends React.Component {
componentDidMount() {
this.initJitsi();
}
componentWillUnmount() {
if (this.api) {
this.api.dispose();
}
}
import styled from 'styled-components';
export const JitsiViewWrapper = styled.div`
&,
#jitsi-mount,
iframe {
width: 100%;
height: 100%;
}
`;
import React from 'react';
import ScriptLoader from 'react-render-props-script-loader';
import JitsiView from './JitsiView';
const JitsiContainer = props => {
// Prepare config e.g. user and room names
const userConfig = { ... }
const roomConfig = { ... }
render() {
return (
<JitsiViewWrapper>
<div id="jitsi-mount" />
</JitsiViewWrapper>
);
}
import { connect } from '../../_db';
import { withAuth } from '../../_utils/auth';
import User from '../../_db/user';
// First check if we need to connect to the database
// Only if there is no live connection will a new one be established
connect();
export default withAuth(async (req, res) => {
if (req.method !== 'POST') {
// next.config.js
module.exports = {
// For variables required on just client side, or on both client and server sides
publicRuntimeConfig: {
proxyApiEndpoint: process.env.EKO_PROXY_API_ENDPOINT,
recaptchaToken: process.env.EKO_RECAPTCHA_SITE_KEY,
},
// For variables required on the server side only
serverRuntimeConfig: {
oauthClientSecret: process.env.EKO_OAUTH_CLIENT_SECRET,
Data fetching method Type of server rendering
None Static
getStaticProps Static
getServerSideProps SSR
getInitialProps SSR
const dev = NODE_ENV !== 'production';
const app = next({ dev });
const handleNextRequest = app.getRequestHandler();
app.prepare().then(() => {
const server = express();
// Apply some middlewares
server.use(...);
server.use(...);