next.js

What's the right way to float right or left using the material-ui appbar with material-ui-next?

心不动则不痛 提交于 2021-02-05 19:07:32
问题 I can't figure out if I'm using the right approach to get the login/logout buttons to float right in while using material-ui-next ("material-ui": "^1.0.0-beta.22",) It seems they removed iconElementRight= from the api. Do we have to use the <Grid> now in the appbar? It feels kinds of cludgy. What's the right way to float buttons (e.g. login) in the appbar? <AppBar position="static"> <Toolbar> <Grid container spacing={24}> <Grid item xs={11}> <Typography type="title" color="inherit"> Title <

What's the right way to float right or left using the material-ui appbar with material-ui-next?

和自甴很熟 提交于 2021-02-05 19:01:04
问题 I can't figure out if I'm using the right approach to get the login/logout buttons to float right in while using material-ui-next ("material-ui": "^1.0.0-beta.22",) It seems they removed iconElementRight= from the api. Do we have to use the <Grid> now in the appbar? It feels kinds of cludgy. What's the right way to float buttons (e.g. login) in the appbar? <AppBar position="static"> <Toolbar> <Grid container spacing={24}> <Grid item xs={11}> <Typography type="title" color="inherit"> Title <

What's the right way to float right or left using the material-ui appbar with material-ui-next?

微笑、不失礼 提交于 2021-02-05 19:00:45
问题 I can't figure out if I'm using the right approach to get the login/logout buttons to float right in while using material-ui-next ("material-ui": "^1.0.0-beta.22",) It seems they removed iconElementRight= from the api. Do we have to use the <Grid> now in the appbar? It feels kinds of cludgy. What's the right way to float buttons (e.g. login) in the appbar? <AppBar position="static"> <Toolbar> <Grid container spacing={24}> <Grid item xs={11}> <Typography type="title" color="inherit"> Title <

Next.js: How to get static assets from within getStaticProps

ぃ、小莉子 提交于 2021-02-05 07:27:30
问题 I am using Netlify CMS. I want to import all the slides for a carousel into my component. I made a collection called slider and added a few slides. That created two markdown files (one for each slide) in public/content/slider/ . I would like to import them all into an iteratable object so I can build the carousel. Because I have a webpack loader set up for markdown files, I can import a single markdown file no problem, like this: import post from '../public/content/posts/[post name].md But

Pass props in url using Next.js

别等时光非礼了梦想. 提交于 2021-01-29 19:40:47
问题 I pass props in url using this: const sendPropsInRoute = (data) => { router.push({ pathname: '/cars/car', query: { data: JSON.stringify(data) }, }, `/agencies/agency`, { shallow: true, }, ) } Everything works fine when i click on the button. I am redirected on the page and i read the data from query in this way: const router = useRouter(); const car = router.query.data; console.log(car) Issue: When i refresh the page where i was redirected i loose the data from query. Question: How to keep

Next.js Add slug/params to clean URL

狂风中的少年 提交于 2021-01-29 18:21:10
问题 I have a structure with a clean URL in the "pages" folder like this ... /pages/items/[pageNumber]/index.tsx And if I use router.push I use it like this to get to that page ... router.replace("/items/[pageNumber]", "/items/1") That works great, but now I want to add a query params (for filter) to that URL, how can I do that? I tried this ... router.push(`/items/[pageNumber]/`, `/items/1/?${filterParams}`, { shallow: true }); But that doesn't work, and I'm wondering how to do that. 回答1: When

How to access method of the child component from parent in reactjs

你。 提交于 2021-01-29 17:47:59
问题 I'm trying to call child component from parent component in reactjs using refs.but it throws error saying showModal() is not a function when I tried to call. //app.js class app extends Component { constructor(props) { super(props); this.POPUP = React.createRef(); } showModal(){ this.POPUP.showModal(true); } render() { return ( <React.Fragment> <span><a onClick={() => this.showModal()}>Show</a></span> <POPUP onRef={ref => (this.POPUP = ref)}></POPUP> </React.Fragment > ) } } popup.js class

Failing to use document object inside of react component. “document is not defined” error

≡放荡痞女 提交于 2021-01-29 15:07:23
问题 I've got some browser sniffing code that I'm using inside of a react component import React, { useState } from 'react' const SomeComponent = ({props}) => { const isIE = document.documentMode; return ( <div> Some browser sniffing code here. </div> ) } I'm getting this error on build, though, "document is not defined" It also fails when I try it like this import React, { useState } from 'react' const isIE = document.documentMode; const SomeComponent = ({props}) => { console.log(isIe) return (

Importing foundation js package inside next project

帅比萌擦擦* 提交于 2021-01-29 14:30:54
问题 I added zurb foundation inside my next project and on the sass side I have no problems importing everything. The problems starts when I want to import the JS packages. I'm not entirely sure where the problem might be, the only thing I could understand this passed days is that it may be a webpack importing problem. Here is the index code import { useState, Component } from 'react'; import { connect } from 'react-redux'; import 'resources/main.scss'; import type { State } from 'AppState/Types';

Using redux with next.js

こ雲淡風輕ζ 提交于 2021-01-29 14:00:35
问题 I use redux in next js in my aplication: //reducer const initialState = { carRequest: false, carSuccess: false, car: {}, error:'' }; export const carReducer = (state = initialState , { type, payload }) => { switch (type) { case HYDRATE: { console.log(state, payload) return { ...state, ...payload, } } case CAR.GET_CAR_ERROR: return { ...state, carRequest: false, carSuccess: false, car: {}, error:payload } case CAR.GET_CAR_SUCCESS: return { ...state, carRequest: false, carSuccess: true, car: