2

I'm not sure if I'm missing something here but when I console.log my attributes I am getting an empty object. Shouldn't it show the default data of all my attributes. What I am doing wrong here.

import { __ } from '@wordpress/i18n';
import { registerBlockType } from '@wordpress/blocks';
import { useEffect } from '@wordpress/blocks';
import { PluginDocumentSettingPanel } from '@wordpress/edit-post';
import GoogleMap from './GoogleMap.js';
import { Component } from '@wordpress/element';
import axios from 'axios';

registerBlockType( 'splash-blocks/google-maps', { 
    title: __('Google maps locations', 'google-maps'),
    icon: 'megaphone',
    category: 'common',
    keyword: [
        __( 'Display Google maps locations' ),
    ],
    atrributes: {
        markers: {
            type: 'array',
            default: [{
                lat: 37.79406,
                lng: -122.4002,
            }],
        },
        icon: {

        },
    address: {
        type: 'string',
        default: 'xxxxxxxxx',
        }, 
        api_key: {
        type: 'string',
        default: 'xxxxxxxxx',
        }
    },
    edit({ attributes, setAttributes }) {

        console.log(attributes)
        //Console shows empty object
        return ( 
            <div id='google-map'>
            </div>
        )
    },
    save: null,
})
1

Your block has no attributes. It does however have atrributes.

Change atrributes to attributes and things should make more sense.

1
  • Sorry, dumb mistake on my part 😐 Apr 30 '21 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.