Skip to content

Commit

Permalink
feat: include id from props not config
Browse files Browse the repository at this point in the history
  • Loading branch information
bangarang committed Apr 26, 2024
1 parent 8e3949f commit 399f9cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apps/react/app/re-used-space/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ const App = () => {
</button>
</div>
<Space
id={SPACE_ID}
config={{
id: SPACE_ID,
metadata: {
sidebarConfig: {
showSidebar: true,
Expand Down
9 changes: 6 additions & 3 deletions packages/react/src/components/Space.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useDeepCompareEffect } from '../utils/useDeepCompareEffect'

type SpaceProps = {
id?: string
config: Flatfile.SpaceConfig
config?: Flatfile.SpaceConfig
children?: React.ReactNode
}

Expand Down Expand Up @@ -33,11 +33,14 @@ type SpaceProps = {
*/

export const Space = (props: SpaceProps) => {
const { config, children } = props
const { config, id, children } = props
const { updateSpace } = useContext(FlatfileContext)

const callback = useCallback(() => {
updateSpace(config)
updateSpace({
...(config || {}),
id,
})
}, [config, updateSpace])

useDeepCompareEffect(callback, [config])
Expand Down

0 comments on commit 399f9cc

Please sign in to comment.