I'm trying to get some data onchain with useContractReads in getServerSideProps
import React from "react"
import {
useContractReads,
} from 'wagmi'
import { ProjectContractAddress, ProjectContractAbi } from '../constants'
export async function getServerSideProps() {
const contract = {
addressOrName: ProjectContractAddress,
contractInterface: ProjectContractAbi,
functionName: 'proposalCount'
}
const { data, isError, isLoading, isSuccess } = useContractReads({
contracts: [
contract,
],
})
result = data?.toString() ?? undefined
return {
props: { result }, // will be passed to the page component as props
}
}
export default function AllProjects({ result }) {
(...)
brower tells me "TypeError: Cannot read properties of null (reading 'useRef')" when the server console tells me "Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons: (...)"
what I am doing wrong ?