react-albus icon indicating copy to clipboard operation
react-albus copied to clipboard

Migration to React 16.x context

Open RusinovAnton opened this issue 5 years ago • 11 comments

Hello, thanks for the great library.

Is it planned to migrate to the latest React versions, especially using stable context API?

RusinovAnton avatar Mar 12 '19 08:03 RusinovAnton

As for React 16.x context, I created my own WizardContext which allows my code to get the albus context via the new 16.x API:

// WizardContext.tsx
import React from "react";
import PropTypes from 'prop-types';
import { WizardContext as AlbusContext } from 'react-albus';

export const WizardContext = React.createContext<AlbusContext>(
  {} as AlbusContext
);

export const WizardProvider: React.FC = ({children}, context) => {
  return (
    <WizardContext.Provider value={context.wizard}>
      {children}
    </WizardContext.Provider>
  );
};

WizardProvider.contextTypes = {
  wizard: PropTypes.object
};

Then in the wizard tsx:

import { WizardProvider } from './WizardContext';
// ...
<Wizard>
  <WizardProvider>
    <Steps>
// ...

Then in a child component tsx:

import { WizardContext } from '../contexts/WizardContext';
// ...
  const {
    next
  } = useContext(WizardContext);
// ...
  <button onClick={next}>Next</button>

Hope this helps. Still hoping 16.x context support will be added soon.

cheungpat avatar Jan 16 '20 04:01 cheungpat

This issue is stale because it has been open 30 days with no activity. Remove no-issue-activity label or comment or this will be closed in 5 days.

github-actions[bot] avatar Apr 07 '20 00:04 github-actions[bot]

I have the same problem, it is important to do the migration!

@cheungpat is a good "solution", but it's only temporary

paulocarvalho2899 avatar Apr 21 '20 16:04 paulocarvalho2899

This issue is stale because it has been open 30 days with no activity.

github-actions[bot] avatar May 22 '20 00:05 github-actions[bot]

sorry for the late response here. We'll be updating to the latest React Context api soon

ryhinchey avatar Mar 04 '21 15:03 ryhinchey

I have the same problem too, is it still supposed to be fixed soon ? Thanks !

araymond11 avatar Aug 19 '21 22:08 araymond11

Hey I am also getting this warning - would be great to have an update!

dmossie avatar Nov 05 '21 23:11 dmossie

@ryhinchey Any news?

paulosalvatore avatar Jul 07 '22 18:07 paulosalvatore

This issue is stale because it has been open 30 days with no activity.

github-actions[bot] avatar Aug 05 '23 00:08 github-actions[bot]

Hello, what has happened to this? Still getting this error.

JAKWeRD avatar Mar 25 '24 08:03 JAKWeRD

This issue is stale because it has been open 30 days with no activity.

github-actions[bot] avatar Apr 25 '24 00:04 github-actions[bot]